name: Build & Publish Release on: workflow_dispatch: inputs: version: description: "Release version (must be 0.x.y, e.g. 0.1.0)" required: true default: "0.1.0" type: string permissions: contents: write jobs: validate: name: Validate Actor, Branch & 0.x.y Version runs-on: ubuntu-latest if: github.actor == 'lucasoskorep' && github.ref == 'refs/heads/master' outputs: version: ${{ steps.check.outputs.version }} tag: ${{ steps.check.outputs.tag }} steps: - name: Validate release trigger id: check run: | if [ "${{ github.actor }}" != "lucasoskorep" ]; then echo "Error: Only lucasoskorep is authorized to run this workflow." >&2 exit 1 fi if [ "${{ github.ref }}" != "refs/heads/master" ]; then echo "Error: Releases may only be built from the master branch (got ${{ github.ref }})." >&2 exit 1 fi RAW_VER="${{ inputs.version }}" VER="${RAW_VER#v}" if ! [[ "$VER" =~ ^0\.[0-9]+\.[0-9]+$ ]]; then echo "Error: Version must be 0.x.y (got '$RAW_VER')." >&2 exit 1 fi echo "version=${VER}" >> "$GITHUB_OUTPUT" echo "tag=v${VER}" >> "$GITHUB_OUTPUT" build: name: Build (${{ matrix.label }}) needs: validate if: github.actor == 'lucasoskorep' && github.ref == 'refs/heads/master' runs-on: ${{ matrix.os }} strategy: fail-fast: true matrix: include: - label: linux-x86_64 os: ubuntu-latest target: x86_64-unknown-linux-gnu - label: macos-arm64 os: macos-14 target: aarch64-apple-darwin - label: macos-x86_64 os: macos-14 target: x86_64-apple-darwin steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install Linux GUI system libraries if: runner.os == 'Linux' run: | sudo apt-get update sudo apt-get install -y \ pkg-config \ libxkbcommon-dev \ libwayland-dev \ libgtk-3-dev \ libxcb-render0-dev \ libxcb-shape0-dev \ libxcb-xfixes0-dev \ libgl1-mesa-dev - name: Setup mise & toolchain uses: jdx/mise-action@v2 - name: Run workspace tests via mise if: matrix.target != 'x86_64-apple-darwin' shell: bash run: mise run test - name: Build & package release archive via mise shell: bash run: mise run package-release "${{ matrix.target }}" "${{ needs.validate.outputs.version }}" - name: Upload release artifact uses: actions/upload-artifact@v4 with: name: release-${{ matrix.label }} path: dist/* if-no-files-found: error publish: name: Publish GitHub Release needs: [validate, build] if: github.actor == 'lucasoskorep' && github.ref == 'refs/heads/master' runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Download all platform artifacts uses: actions/download-artifact@v4 with: path: release-assets merge-multiple: true - name: Generate SHA256SUMS.txt run: | cd release-assets sha256sum * > SHA256SUMS.txt cat SHA256SUMS.txt - name: Create GitHub Tag & Release uses: softprops/action-gh-release@v2 with: tag_name: ${{ needs.validate.outputs.tag }} target_commitish: ${{ github.sha }} name: ${{ needs.validate.outputs.tag }} generate_release_notes: true files: | release-assets/*