-
Notifications
You must be signed in to change notification settings - Fork 3
177 lines (174 loc) · 5.91 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: CI
on:
pull_request:
push:
branches:
- main
tags:
- v*
jobs:
spec:
name: Spec
runs-on: ubuntu-latest
container: 84codes/crystal:latest-alpine
steps:
- uses: actions/checkout@v4
- name: Shards install
run: shards install --production
- name: Spec
run: crystal spec --no-color --order random
format:
name: Formatting
runs-on: ubuntu-latest
container: 84codes/crystal:latest-alpine
steps:
- uses: actions/checkout@v4
- name: Format check
run: crystal tool format --check
lint:
name: Lint/Ameba
runs-on: ubuntu-latest
container: 84codes/crystal:latest-alpine
steps:
- name: Install make
run: apk add --no-cache make yaml-dev
- name: Checkout
uses: actions/checkout@v4
- name: Shards install
run: shards install
- name: Spec
run: bin/ameba --no-color
docker:
name: Docker container
needs: [spec, format, lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/metadata-action@v5
id: meta
with:
images: 84codes/sparoid
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=ref,event=tag
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push container
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
cache-from: type=gha
cache-to: type=gha,mode=max
deb:
name: Deb package
needs: [spec, format, lint]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, debian-10, debian-11, debian-12]
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
name: Build
with:
file: deb.dockerfile
platforms: linux/${{ matrix.arch }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
build_image=84codes/crystal:latest-${{ matrix.os }}
outputs: builds
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: deb-${{ matrix.arch }}-${{ matrix.os }}
path: builds/
- name: Upload to PackageCloud
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
set -eux
curl -fsSO -u "${{ secrets.packagecloud_token }}:" https://packagecloud.io/api/v1/distributions.json
PKG_FILE=$(find builds -name "*.deb" | head -1)
ID=$(echo $PKG_FILE | cut -d/ -f2)
VERSION_CODENAME=$(echo $PKG_FILE | cut -d/ -f3)
DIST_ID=$(jq ".deb[] | select(.index_name == \"${ID}\").versions[] | select(.index_name == \"${VERSION_CODENAME}\").id" distributions.json)
curl -fsS -u "${{ secrets.packagecloud_token }}:" -XPOST \
-F "package[distro_version_id]=${DIST_ID}" \
-F "package[package_file]=@${PKG_FILE}" \
https://packagecloud.io/api/v1/repos/cloudamqp/sparoid/packages.json
rpm:
name: RPM package
needs: [spec, format, lint]
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
os: [fedora-39, fedora-40]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
file: rpm.dockerfile
platforms: linux/${{ matrix.arch }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
build_image=84codes/crystal:latest-${{ matrix.os }}
outputs: builds
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: rpm-${{ matrix.arch }}-${{ matrix.os }}
path: builds/
- name: Upload to PackageCloud
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
set -eux
curl -fsSO -u "${{ secrets.packagecloud_token }}:" https://packagecloud.io/api/v1/distributions.json
ID=$(echo ${{ matrix.os }} | cut -d- -f1)
VR=$(echo ${{ matrix.os }} | cut -d- -f2)
DIST_ID=$(jq ".rpm[] | select(.index_name == \"${ID}\").versions[] | select(.index_name == \"${VR}\").id" distributions.json)
find builds -name "*.rpm" | xargs -i \
curl -fsS -u "${{ secrets.packagecloud_token }}:" -XPOST \
-F "package[distro_version_id]=${DIST_ID}" \
-F "package[package_file]=@{}" \
https://packagecloud.io/api/v1/repos/cloudamqp/sparoid/packages.json
tar:
runs-on: ubuntu-latest
needs: [spec, format, lint]
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Build tar package
uses: docker/build-push-action@v6
with:
file: tar.dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: .
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: tar
path: ./*.tar.gz
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
files: '*.tar.gz'
fail_on_unmatched_files: true