Refactor release workflow with build and artifact upload #3
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 | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| permissions: | |
| contents: read # only need to check out code | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: sudo apt-get update && sudo apt-get install -y build-essential | |
| - name: Build | |
| working-directory: ./mas | |
| shell: bash | |
| run: make | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binary-${{ runner.os }} | |
| path: | | |
| mas/mas | |
| mas/mas.exe | |
| if-no-files-found: ignore | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # required to publish release | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all binaries | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Flatten and rename binaries | |
| run: | | |
| mkdir -p release-assets | |
| # Linux | |
| if [ -f "artifacts/binary-Ubuntu/mas/mas" ]; then | |
| cp "artifacts/binary-Ubuntu/mas/mas" release-assets/mas-linux | |
| fi | |
| # macOS | |
| if [ -f "artifacts/binary-macOS/mas/mas" ]; then | |
| cp "artifacts/binary-macOS/mas/mas" release-assets/mas-macos | |
| fi | |
| # Windows | |
| if [ -f "artifacts/binary-Windows/mas/mas.exe" ]; then | |
| cp "artifacts/binary-Windows/mas/mas.exe" release-assets/mas-windows.exe | |
| fi | |
| - name: Publish to GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: release-assets/* | |
| tag_name: ${{ github.ref_name }} | |
| name: Release ${{ github.ref_name }} | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |