Skip to content
File

Blob: .github/workflows/rolling-release.yaml

yaml152 lines
1name: Rolling Release
2 
3on:
4 workflow_run:
5 workflows: ["CI"]
6 types: [completed]
7 
8permissions:
9 checks: read
10 contents: write
11 
12jobs:
13 verify:
14 name: Verify Edge Release
15 runs-on: ubuntu-latest
16 if: ${{ github.event.workflow_run.conclusion == 'success' }}
17 outputs:
18 should_release: ${{ steps.check.outputs.should_release }}
19 steps:
20 - name: Check `edge` tag matches CI commit
21 id: check
22 uses: actions/github-script@v6
23 with:
24 github-token: ${{ secrets.GITHUB_TOKEN }}
25 script: |
26 const tag = await github.rest.git.getRef({
27 owner: context.repo.owner,
28 repo: context.repo.repo,
29 ref: 'tags/edge'
30 });
31 const edgeSha = tag.data.object.sha;
32 const ciSha = context.payload.workflow_run.head_sha;
33 if (edgeSha !== ciSha) {
34 console.log(`⚠️ edge tag (${edgeSha}) ≠ CI commit (${ciSha}); skipping release.`);
35 core.setOutput('should_release', 'false');
36 return;
37 }
38 core.setOutput('should_release', 'true');
39 console.log('✅ edge tag matches; proceeding with release.');
40
41 build:
42 name: Build Binaries and Linux Packages
43 needs: verify
44 if: ${{ needs.verify.outputs.should_release == 'true' }}
45 runs-on: ubuntu-latest
46 steps:
47 - name: Checkout CI-tested commit
48 uses: actions/checkout@v6
49 with:
50 ref: ${{ github.event.workflow_run.head_sha }}
51 
52 - name: Set up Go
53 uses: actions/setup-go@v6
54 with:
55 go-version: "1.27.1"
56 
57 - name: Set up Node.js
58 uses: actions/setup-node@v4
59 with:
60 node-version: "22.14.0"
61 cache: npm
62 cache-dependency-path: ui/package-lock.json
63 
64 - name: Build UI
65 run: make ui
66 
67 - name: Build release binaries with WAL helper
68 run: make -j$(nproc) release wal=1
69 
70 - name: Build compatibility binaries
71 run: make -j$(nproc) compat
72 
73 - name: Build Linux packages
74 run: make package-linux
75 
76 - name: Upload release binaries
77 uses: actions/upload-artifact@v4
78 with:
79 name: edge-release-binaries
80 if-no-files-found: error
81 path: |
82 bin/**
83 dist/pkg/linux/**/*.deb
84 dist/pkg/linux/**/*.rpm
85
86 publish:
87 name: Publish Edge Release
88 needs: [verify, build]
89 if: ${{ needs.verify.outputs.should_release == 'true' }}
90 runs-on: ubuntu-latest
91 steps:
92 - name: Download all artifacts
93 uses: actions/download-artifact@v4
94 with:
95 path: release
96 
97 - name: Remove stale Linux package assets
98 uses: actions/github-script@v6
99 with:
100 github-token: ${{ secrets.GITHUB_TOKEN }}
101 script: |
102 const assetPattern = /\.(deb|rpm)$/;
103 let release;
104 try {
105 const response = await github.rest.repos.getReleaseByTag({
106 owner: context.repo.owner,
107 repo: context.repo.repo,
108 tag: 'edge',
109 });
110 release = response.data;
111 } catch (error) {
112 if (error.status === 404) {
113 console.log('No existing edge release found; nothing to prune.');
114 return;
115 }
116 throw error;
117 }
118
119 const assets = await github.paginate(github.rest.repos.listReleaseAssets, {
120 owner: context.repo.owner,
121 repo: context.repo.repo,
122 release_id: release.id,
123 per_page: 100,
124 });
125 
126 const staleAssets = assets.filter((asset) => assetPattern.test(asset.name));
127 if (staleAssets.length === 0) {
128 console.log('No stale .deb or .rpm assets found.');
129 return;
130 }
131 
132 for (const asset of staleAssets) {
133 console.log(`Deleting stale asset: ${asset.name}`);
134 await github.rest.repos.deleteReleaseAsset({
135 owner: context.repo.owner,
136 repo: context.repo.repo,
137 asset_id: asset.id,
138 });
139 }
140 
141 - name: Publish rolling “edge” release
142 uses: softprops/action-gh-release@v1
143 with:
144 name: "Automatic Build on main branch"
145 body: |
146 This is a rolling release with the latest build artifacts
147 on main branch. The release is updated every time the
148 `edge` tag is moved.
149 prerelease: true
150 tag_name: edge
151 files: release/**/*