Your music, beautifully tracked. All yours. (coming soon)
teal.fm
teal-fm
atproto
1# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2
3name: Release
4
5on:
6 push:
7 tags:
8 - "v*"
9 workflow_dispatch:
10 inputs:
11 tag:
12 description: "Release tag"
13 required: true
14 type: string
15
16env:
17 REGISTRY: ghcr.io
18 CARGO_TERM_COLOR: always
19 SQLX_OFFLINE: true
20
21jobs:
22 create-release:
23 name: Create Release
24 runs-on: ubuntu-latest
25 outputs:
26 release_id: ${{ steps.create_release.outputs.id }}
27 upload_url: ${{ steps.create_release.outputs.upload_url }}
28 tag: ${{ steps.tag.outputs.tag }}
29 steps:
30 - name: Checkout repository
31 uses: actions/checkout@v4
32
33 - name: Get tag name
34 id: tag
35 run: |
36 if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
37 echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
38 else
39 echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
40 fi
41
42 - name: Generate changelog
43 id: changelog
44 run: |
45 if [ -f "CHANGELOG.md" ]; then
46 # Extract changelog for this version
47 awk '/^## \[${{ steps.tag.outputs.tag }}\]/{flag=1; next} /^## \[/{flag=0} flag' CHANGELOG.md > release_notes.md
48 else
49 echo "Release ${{ steps.tag.outputs.tag }}" > release_notes.md
50 fi
51
52 - name: Create Release
53 id: create_release
54 uses: actions/create-release@v1
55 env:
56 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57 with:
58 tag_name: ${{ steps.tag.outputs.tag }}
59 release_name: Release ${{ steps.tag.outputs.tag }}
60 body_path: release_notes.md
61 draft: false
62 prerelease: ${{ contains(steps.tag.outputs.tag, '-') }}
63
64 build-all:
65 name: Build All Artifacts
66 runs-on: ubuntu-latest
67 needs: create-release
68 outputs:
69 rust-artifacts: ${{ steps.upload-rust.outputs.artifact-id }}
70 node-artifacts: ${{ steps.upload-node.outputs.artifact-id }}
71 steps:
72 - name: Checkout repository
73 uses: actions/checkout@v4
74
75 - name: Setup environment
76 uses: ./.github/actions/setup
77 with:
78 setup-rust: "true"
79 setup-node: "true"
80 cache-key-suffix: "release-${{ needs.create-release.outputs.tag }}"
81
82 - name: Install cross-compilation tools
83 run: |
84 cargo install cross
85 rustup target add aarch64-unknown-linux-gnu
86
87 - name: Build Node.js artifacts
88 run: |
89 pnpm build
90 cd apps/amethyst && pnpm build
91
92 - name: Build Rust services (x86_64)
93 run: |
94 cd services
95 cargo build --release --all-features
96
97 - name: Build Rust services (aarch64)
98 run: |
99 cd services
100 cross build --release --all-features --target aarch64-unknown-linux-gnu
101
102 - name: Build Rust apps (x86_64)
103 run: |
104 cd apps/aqua
105 cargo build --release --all-features
106
107 - name: Build Rust apps (aarch64)
108 run: |
109 cd apps/aqua
110 cross build --release --all-features --target aarch64-unknown-linux-gnu
111
112 - name: Create Amethyst build archive
113 run: |
114 cd apps/amethyst
115 tar -czf amethyst-${{ needs.create-release.outputs.tag }}.tar.gz build/
116
117 - name: Upload Rust build artifacts
118 id: upload-rust
119 uses: actions/upload-artifact@v4
120 with:
121 name: rust-release-builds
122 path: |
123 target/release/
124 target/aarch64-unknown-linux-gnu/release/
125 apps/aqua/target/release/
126 apps/aqua/target/aarch64-unknown-linux-gnu/release/
127 retention-days: 7
128
129 - name: Upload Node build artifacts
130 id: upload-node
131 uses: actions/upload-artifact@v4
132 with:
133 name: node-release-builds
134 path: |
135 packages/*/dist/
136 apps/amethyst/build/
137 apps/amethyst/amethyst-${{ needs.create-release.outputs.tag }}.tar.gz
138 retention-days: 7
139
140 - name: Upload Amethyst build to release
141 uses: actions/upload-release-asset@v1
142 env:
143 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144 with:
145 upload_url: ${{ needs.create-release.outputs.upload_url }}
146 asset_path: ./apps/amethyst/amethyst-${{ needs.create-release.outputs.tag }}.tar.gz
147 asset_name: amethyst-${{ needs.create-release.outputs.tag }}.tar.gz
148 asset_content_type: application/gzip
149
150 release-services:
151 name: Release Services
152 runs-on: ubuntu-latest
153 needs: [create-release, build-all]
154 permissions:
155 contents: read
156 packages: write
157 strategy:
158 matrix:
159 service:
160 - name: aqua
161 dockerfile: apps/aqua/Dockerfile
162 context: .
163 - name: cadet
164 dockerfile: services/cadet/Dockerfile
165 context: .
166 - name: rocketman
167 dockerfile: services/rocketman/Dockerfile
168 context: .
169 - name: satellite
170 dockerfile: services/satellite/Dockerfile
171 context: .
172 steps:
173 - name: Checkout repository
174 uses: actions/checkout@v4
175
176 - name: Check if service has Dockerfile
177 id: check
178 run: |
179 if [ -f "${{ matrix.service.dockerfile }}" ]; then
180 echo "has_dockerfile=true" >> $GITHUB_OUTPUT
181 echo "Service ${{ matrix.service.name }} has Dockerfile"
182 else
183 echo "has_dockerfile=false" >> $GITHUB_OUTPUT
184 echo "Service ${{ matrix.service.name }} does not have Dockerfile, skipping"
185 fi
186
187 - name: Setup environment
188 if: steps.check.outputs.has_dockerfile == 'true'
189 uses: ./.github/actions/setup
190 with:
191 setup-node: "true"
192 lexicons-only-rust: "true"
193
194 - name: Download build artifacts
195 if: steps.check.outputs.has_dockerfile == 'true'
196 uses: actions/download-artifact@v4
197 with:
198 name: rust-release-builds
199 path: .
200
201 - name: Log in to Container Registry
202 if: steps.check.outputs.has_dockerfile == 'true'
203 uses: docker/login-action@v3
204 with:
205 registry: ${{ env.REGISTRY }}
206 username: ${{ github.actor }}
207 password: ${{ secrets.GITHUB_TOKEN }}
208
209 - name: Extract metadata
210 if: steps.check.outputs.has_dockerfile == 'true'
211 id: meta
212 uses: docker/metadata-action@v5
213 with:
214 images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.service.name }}
215 tags: |
216 type=raw,value=latest
217 type=raw,value=${{ needs.create-release.outputs.tag }}
218
219 - name: Set up Docker Buildx
220 if: steps.check.outputs.has_dockerfile == 'true'
221 uses: docker/setup-buildx-action@v3
222
223 - name: Build and push Docker image
224 if: steps.check.outputs.has_dockerfile == 'true'
225 uses: docker/build-push-action@v5
226 with:
227 context: ${{ matrix.service.context }}
228 file: ${{ matrix.service.dockerfile }}
229 push: true
230 tags: ${{ steps.meta.outputs.tags }}
231 labels: ${{ steps.meta.outputs.labels }}
232 platforms: linux/amd64,linux/arm64
233 cache-from: type=gha,scope=${{ matrix.service.name }}
234 cache-to: type=gha,mode=max,scope=${{ matrix.service.name }}
235 build-args: |
236 BUILDKIT_INLINE_CACHE=1