|
1 | | -# SPDX-License-Identifier: PMPL-1.0-or-later |
2 | | -# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk> |
3 | | -# |
4 | | -# Release workflow — triggered by version tags (v*). |
5 | | -# Builds artifacts, generates changelog via git-cliff, creates a GitHub Release, |
6 | | -# and produces SLSA provenance attestations. |
7 | 1 | name: Release |
8 | 2 |
|
9 | 3 | on: |
10 | 4 | push: |
11 | 5 | tags: |
12 | 6 | - 'v*' |
13 | 7 |
|
14 | | -permissions: |
15 | | - contents: read |
16 | | - |
17 | 8 | jobs: |
18 | | - build: |
19 | | - name: Build Artifacts |
20 | | - runs-on: ubuntu-latest |
21 | | - permissions: |
22 | | - contents: read |
23 | | - steps: |
24 | | - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
25 | | - |
26 | | - - name: Detect project type and build |
27 | | - id: build |
28 | | - run: | |
29 | | - # Auto-detect build system from project files. |
30 | | - # Order matters: more specific markers checked first. |
31 | | - if [ -f "mix.exs" ]; then |
32 | | - echo "::notice::Detected Elixir/Gleam project (mix.exs)" |
33 | | - echo "build_type=mix" >> "$GITHUB_OUTPUT" |
34 | | - mix local.hex --force --if-missing |
35 | | - mix local.rebar --force --if-missing |
36 | | - mix deps.get --only prod |
37 | | - MIX_ENV=prod mix release |
38 | | - elif [ -f "Cargo.toml" ]; then |
39 | | - echo "::notice::Detected Rust project (Cargo.toml)" |
40 | | - echo "build_type=cargo" >> "$GITHUB_OUTPUT" |
41 | | - cargo build --release |
42 | | - elif [ -f "build.zig" ]; then |
43 | | - echo "::notice::Detected Zig project (build.zig)" |
44 | | - echo "build_type=zig" >> "$GITHUB_OUTPUT" |
45 | | - zig build -Doptimize=ReleaseSafe |
46 | | - elif [ -f "deno.json" ] || [ -f "deno.jsonc" ]; then |
47 | | - echo "::notice::Detected Deno project (deno.json)" |
48 | | - echo "build_type=deno" >> "$GITHUB_OUTPUT" |
49 | | - deno task build |
50 | | - elif [ -f "gossamer.conf.json" ]; then |
51 | | - echo "::notice::Detected Gossamer project (gossamer.conf.json)" |
52 | | - echo "build_type=gossamer" >> "$GITHUB_OUTPUT" |
53 | | - gossamer build |
54 | | - elif [ -f "gleam.toml" ]; then |
55 | | - echo "::notice::Detected Gleam project (gleam.toml)" |
56 | | - echo "build_type=gleam" >> "$GITHUB_OUTPUT" |
57 | | - gleam build |
58 | | - elif [ -f "rebar.config" ]; then |
59 | | - echo "::notice::Detected Erlang/Rebar project (rebar.config)" |
60 | | - echo "build_type=rebar" >> "$GITHUB_OUTPUT" |
61 | | - rebar3 as prod release |
62 | | - elif [ -f "Justfile" ] || [ -f "justfile" ]; then |
63 | | - echo "::notice::Detected Justfile — running 'just build'" |
64 | | - echo "build_type=just" >> "$GITHUB_OUTPUT" |
65 | | - just build |
66 | | - else |
67 | | - echo "::error::No recognised build system found." |
68 | | - echo "Expected one of: mix.exs, Cargo.toml, build.zig, deno.json, gossamer.conf.json, gleam.toml, rebar.config, Justfile" |
69 | | - exit 1 |
70 | | - fi |
71 | | -
|
72 | | - # TODO: Upload build artifacts if needed |
73 | | - # - uses: actions/upload-artifact@v4 |
74 | | - # with: |
75 | | - # name: release-artifacts |
76 | | - # path: target/release/ |
77 | | - |
78 | | - changelog: |
79 | | - name: Generate Changelog |
80 | | - runs-on: ubuntu-latest |
81 | | - permissions: |
82 | | - contents: read |
83 | | - outputs: |
84 | | - changelog: ${{ steps.cliff.outputs.content }} |
85 | | - version: ${{ steps.version.outputs.version }} |
86 | | - steps: |
87 | | - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
88 | | - with: |
89 | | - fetch-depth: 0 |
90 | | - |
91 | | - - name: Extract version from tag |
92 | | - id: version |
93 | | - run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" |
94 | | - |
95 | | - - name: Install git-cliff |
96 | | - run: | |
97 | | - curl -sSfL https://github.com/orhun/git-cliff/releases/latest/download/git-cliff-$(uname -m)-unknown-linux-gnu.tar.gz \ |
98 | | - | tar -xz --strip-components=1 -C /usr/local/bin/ git-cliff-*/git-cliff |
99 | | -
|
100 | | - - name: Generate changelog for this release |
101 | | - id: cliff |
102 | | - run: | |
103 | | - # Generate changelog for the current tag only |
104 | | - CHANGELOG=$(git cliff --latest --strip header) |
105 | | - # Write to output using delimiter to handle multiline |
106 | | - { |
107 | | - echo "content<<CLIFF_EOF" |
108 | | - echo "$CHANGELOG" |
109 | | - echo "CLIFF_EOF" |
110 | | - } >> "$GITHUB_OUTPUT" |
111 | | -
|
112 | | - - name: Update full CHANGELOG.md |
113 | | - run: | |
114 | | - git cliff --output CHANGELOG.md |
115 | | -
|
116 | | - - name: Upload updated CHANGELOG.md |
117 | | - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
118 | | - with: |
119 | | - name: changelog |
120 | | - path: CHANGELOG.md |
121 | | - retention-days: 5 |
122 | | - |
123 | 9 | release: |
124 | | - name: Create GitHub Release |
125 | | - needs: [build, changelog] |
126 | 10 | runs-on: ubuntu-latest |
127 | | - permissions: |
128 | | - contents: write |
129 | 11 | steps: |
130 | | - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
131 | | - |
132 | | - # TODO: Download build artifacts if uploading to the release |
133 | | - # - uses: actions/download-artifact@v4 |
134 | | - # with: |
135 | | - # name: release-artifacts |
136 | | - # path: artifacts/ |
137 | | - |
| 12 | + - uses: actions/checkout@v4 |
138 | 13 | - name: Create GitHub Release |
139 | | - uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2 |
| 14 | + uses: softprops/action-gh-release@v2 |
140 | 15 | with: |
141 | | - body: ${{ needs.changelog.outputs.changelog }} |
142 | | - draft: false |
143 | | - prerelease: ${{ contains(github.ref_name, '-rc') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-alpha') }} |
144 | | - generate_release_notes: false |
145 | | - # TODO: Add artifact files to the release |
146 | | - # files: | |
147 | | - # artifacts/* |
148 | | - env: |
149 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
150 | | - |
151 | | - provenance: |
152 | | - name: SLSA Provenance |
153 | | - needs: [build] |
154 | | - permissions: |
155 | | - actions: read |
156 | | - id-token: write |
157 | | - contents: write |
158 | | - # SLSA generator must run in a separate, isolated workflow |
159 | | - # See: https://slsa.dev/spec/v1.0/requirements#build-l3 |
160 | | - uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@f7dd8c54c2067bafc12ca7a55595d5ee9b75204a # v2.1.0 |
161 | | - with: |
162 | | - base64-subjects: "" |
163 | | - # TODO: Replace with actual artifact hashes |
164 | | - # Generate with: sha256sum artifact | base64 -w0 |
165 | | - # base64-subjects: "${{ needs.build.outputs.hashes }}" |
| 16 | + files: | |
| 17 | + docs/whitepapers/academic/snif.pdf |
0 commit comments