release-build #106
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: release-build | |
| on: | |
| push: | |
| tags: ['v*'] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: ${{ matrix.platform }} | |
| strategy: | |
| # Don't fail-fast: one slow or flaky platform shouldn't cancel | |
| # the others mid-matrix and block the draft release. | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: linux-amd64 | |
| runner: ubuntu-22.04 | |
| os: linux | |
| arch: amd64 | |
| ext: tar.gz | |
| exe: "" | |
| - platform: linux-arm64 | |
| runner: ubuntu-22.04-arm | |
| os: linux | |
| arch: arm64 | |
| ext: tar.gz | |
| exe: "" | |
| - platform: darwin-amd64 | |
| runner: macos-15-intel | |
| os: darwin | |
| arch: amd64 | |
| ext: tar.gz | |
| exe: "" | |
| - platform: darwin-arm64 | |
| runner: macos-15 | |
| os: darwin | |
| arch: arm64 | |
| ext: tar.gz | |
| exe: "" | |
| - platform: windows-amd64 | |
| runner: windows-latest | |
| os: windows | |
| arch: amd64 | |
| ext: zip | |
| exe: ".exe" | |
| runs-on: ${{ matrix.runner }} | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| CC: ${{ matrix.os == 'windows' && 'gcc' || 'cc' }} | |
| TAG: ${{ github.ref_name }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Verify tag matches src/mino.h | |
| run: | | |
| src_ver="v$(awk ' | |
| /^#define MINO_VERSION_MAJOR/ {maj=$3} | |
| /^#define MINO_VERSION_MINOR/ {min=$3} | |
| /^#define MINO_VERSION_PATCH/ {pat=$3} | |
| END {print maj"."min"."pat} | |
| ' src/mino.h)" | |
| tag_base="${TAG%%-*}" | |
| if [ "$src_ver" != "$tag_base" ]; then | |
| echo "Tag $TAG (base $tag_base) does not match src/mino.h version $src_ver" >&2 | |
| exit 1 | |
| fi | |
| echo "Tag $TAG matches source version $src_ver" | |
| - name: Bootstrap mino | |
| # The Makefile detects Windows via $(OS) and produces mino.exe | |
| # there, mino elsewhere; matches matrix.exe by construction. | |
| # Tee the output so a build break leaves a downloadable | |
| # artifact even though release-build runs on tags only. | |
| run: | | |
| set -o pipefail | |
| make 2>&1 | tee /tmp/build.log | |
| - name: Upload build log on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-log-${{ matrix.platform }} | |
| path: /tmp/build.log | |
| retention-days: 7 | |
| - name: Smoke test | |
| run: | | |
| "./mino${{ matrix.exe }}" --version | |
| out=$("./mino${{ matrix.exe }}" -e '(+ 1 2)') | |
| if [ "$out" != "3" ]; then | |
| echo "Smoke test failed: expected '3', got '$out'" >&2 | |
| exit 1 | |
| fi | |
| - name: Stage release directory | |
| run: | | |
| dir="mino_${{ matrix.os }}_${{ matrix.arch }}_${TAG}" | |
| mkdir -p "$dir" | |
| cp "mino${{ matrix.exe }}" "$dir/" | |
| cp LICENSE "$dir/" | |
| sed \ | |
| -e "s/__VERSION__/${TAG}/g" \ | |
| -e "s/__OS__/${{ matrix.os }}/g" \ | |
| -e "s/__ARCH__/${{ matrix.arch }}/g" \ | |
| .github/release-templates/release-readme.md > "$dir/README.md" | |
| echo "STAGE_DIR=$dir" >> "$GITHUB_ENV" | |
| - name: Archive | |
| run: | | |
| if [ "${{ matrix.ext }}" = "zip" ]; then | |
| 7z a -tzip "${STAGE_DIR}.zip" "${STAGE_DIR}" >/dev/null | |
| else | |
| tar -czf "${STAGE_DIR}.tar.gz" "${STAGE_DIR}" | |
| fi | |
| ls -la "${STAGE_DIR}.${{ matrix.ext }}" | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.platform }} | |
| path: mino_${{ matrix.os }}_${{ matrix.arch }}_${{ github.ref_name }}.${{ matrix.ext }} | |
| if-no-files-found: error | |
| retention-days: 7 | |
| publish-draft: | |
| name: publish draft release | |
| needs: build | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Generate checksums.txt | |
| working-directory: dist | |
| run: | | |
| shasum -a 256 mino_* > checksums.txt | |
| cat checksums.txt | |
| - name: Create draft Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: ${{ github.ref_name }} | |
| draft: true | |
| prerelease: ${{ contains(github.ref_name, '-') }} | |
| fail_on_unmatched_files: true | |
| files: | | |
| dist/mino_* | |
| dist/checksums.txt |