@@ -22,39 +22,8 @@ concurrency:
2222 cancel-in-progress : true
2323
2424jobs :
25- resolve-version :
26- name : Resolve Release Version
27- runs-on : blacksmith-2vcpu-ubuntu-2404
28- outputs :
29- version : ${{ steps.resolve.outputs.version }}
30- steps :
31- - name : Checkout
32- uses : useblacksmith/checkout@41cdeedae8edb2e684ba22896a5fd2a3cb85db6b
33- with :
34- persist-credentials : false
35-
36- - name : Resolve version label
37- id : resolve
38- shell : bash
39- run : |
40- set -euo pipefail
41- raw_version="${{ github.event.inputs.version }}"
42- if [[ "${GITHUB_REF_TYPE:-}" == "tag" ]]; then
43- raw_version="${GITHUB_REF_NAME}"
44- fi
45- if [[ -z "${raw_version}" ]]; then
46- raw_version="$(awk -F'"' '/^version = "/ {print $2; exit}' Cargo.toml)"
47- fi
48- normalized_version="${raw_version#v}"
49- if [[ ! "${normalized_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
50- echo "Invalid release version: ${raw_version}" >&2
51- exit 1
52- fi
53- echo "version=${normalized_version}" >> "${GITHUB_OUTPUT}"
54-
5525 build-linux :
5626 name : Build Linux (${{ matrix.target }})
57- needs : resolve-version
5827 runs-on : ${{ matrix.runner }}
5928 timeout-minutes : 60
6029 strategy :
7948 - name : Restore Rust cache
8049 uses : Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4
8150
51+ - name : Resolve release version
52+ shell : bash
53+ env :
54+ RAW_RELEASE_VERSION : ${{ github.ref_type == 'tag' && github.ref_name || github.event.inputs.version || '' }}
55+ run : |
56+ set -euo pipefail
57+ raw_version="${RAW_RELEASE_VERSION}"
58+ if [[ -z "${raw_version}" ]]; then
59+ raw_version="$(awk -F'"' '/^version = "/ {print $2; exit}' Cargo.toml)"
60+ fi
61+ normalized_version="${raw_version#v}"
62+ if [[ ! "${normalized_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
63+ echo "Invalid release version: ${raw_version}" >&2
64+ exit 1
65+ fi
66+ echo "RELEASE_VERSION=${normalized_version}" >> "${GITHUB_ENV}"
67+
8268 - name : Build and package Linux release artifacts
83- run : scripts/package-linux-release.sh --target "${{ matrix.target }}" --version "${{ needs.resolve-version.outputs.version } }"
69+ run : scripts/package-linux-release.sh --target "${{ matrix.target }}" --version "${RELEASE_VERSION }"
8470
8571 - name : Upload Linux release artifacts
8672 uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
9682
9783 build-macos :
9884 name : Build macOS (${{ matrix.target }})
99- needs : resolve-version
10085 runs-on : ${{ matrix.runner }}
10186 timeout-minutes : 60
10287 strategy :
@@ -121,9 +106,26 @@ jobs:
121106 - name : Restore Rust cache
122107 uses : Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4
123108
109+ - name : Resolve release version
110+ shell : bash
111+ env :
112+ RAW_RELEASE_VERSION : ${{ github.ref_type == 'tag' && github.ref_name || github.event.inputs.version || '' }}
113+ run : |
114+ set -euo pipefail
115+ raw_version="${RAW_RELEASE_VERSION}"
116+ if [[ -z "${raw_version}" ]]; then
117+ raw_version="$(awk -F'"' '/^version = "/ {print $2; exit}' Cargo.toml)"
118+ fi
119+ normalized_version="${raw_version#v}"
120+ if [[ ! "${normalized_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
121+ echo "Invalid release version: ${raw_version}" >&2
122+ exit 1
123+ fi
124+ echo "RELEASE_VERSION=${normalized_version}" >> "${GITHUB_ENV}"
125+
124126 - name : Build and package macOS release artifacts
125127 shell : bash
126- run : scripts/package-macos-release.sh --target "${{ matrix.target }}" --version "${{ needs.resolve-version.outputs.version } }"
128+ run : scripts/package-macos-release.sh --target "${{ matrix.target }}" --version "${RELEASE_VERSION }"
127129
128130 - name : Upload macOS release artifacts
129131 uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
@@ -137,7 +139,6 @@ jobs:
137139
138140 build-windows :
139141 name : Build Windows (${{ matrix.target }})
140- needs : resolve-version
141142 runs-on : ${{ matrix.runner }}
142143 timeout-minutes : 60
143144 strategy :
@@ -160,9 +161,24 @@ jobs:
160161 - name : Restore Rust cache
161162 uses : Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4
162163
164+ - name : Resolve release version
165+ shell : pwsh
166+ env :
167+ RAW_RELEASE_VERSION : ${{ github.ref_type == 'tag' && github.ref_name || github.event.inputs.version || '' }}
168+ run : |
169+ $RawVersion = $env:RAW_RELEASE_VERSION
170+ if (-not $RawVersion) {
171+ $RawVersion = Select-String -Path "Cargo.toml" -Pattern '^version = "(.+)"$' | Select-Object -First 1 | ForEach-Object { $_.Matches[0].Groups[1].Value }
172+ }
173+ $NormalizedVersion = $RawVersion -replace '^v', ''
174+ if ($NormalizedVersion -notmatch '^\d+\.\d+\.\d+$') {
175+ throw "Invalid release version: $RawVersion"
176+ }
177+ "RELEASE_VERSION=$NormalizedVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
178+
163179 - name : Build and package Windows release artifacts
164180 shell : pwsh
165- run : scripts/package-windows-release.ps1 -Target "${{ matrix.target }}" -Version "${{ needs.resolve-version.outputs.version } }"
181+ run : scripts/package-windows-release.ps1 -Target "${{ matrix.target }}" -Version "${env:RELEASE_VERSION }"
166182
167183 - name : Upload Windows release artifacts
168184 uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
@@ -178,7 +194,6 @@ jobs:
178194 name : Publish GitHub Release
179195 if : ${{ github.event_name == 'push' }}
180196 needs :
181- - resolve-version
182197 - build-linux
183198 - build-macos
184199 - build-windows
0 commit comments