Build release assets using GitHub Actions #10
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: Build & attach tarballs on tag push | |
| on: | |
| push: | |
| tags: ['v[0-9]*'] | |
| permissions: | |
| contents: write | |
| id-token: write | |
| env: | |
| TAG: ${{ github.ref_name }} | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| include: | |
| # - { target: x86_64, os: ubuntu-24.04 } | |
| - { target: aarch64, os: ubuntu-24.04-arm } | |
| # - { target: arm, os: ubuntu-24.04-arm } | |
| # - { target: riscv64, os: ubuntu-24.04 } | |
| # - { target: ppc64le, os: ubuntu-24.04 } | |
| # - { target: s390x, os: ubuntu-24.04 } | |
| # - { target: loongarch64, os: ubuntu-24.04 } | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Podman | |
| run: sudo apt-get update && sudo apt-get install -y podman qemu-user-static | |
| - name: Login to GitHub Container Registry | |
| uses: redhat-actions/podman-login@v1 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build distribution tarballs | |
| run: ./dist.sh ${{ matrix.target }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.target }} | |
| path: dist/mold-*.tar.gz | |
| publish: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| pattern: '*' | |
| merge-multiple: true | |
| - name: Ensure release exists (create if missing) | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -e | |
| if gh release view "$TAG" >& /dev/null; then | |
| echo "Existing release found for $TAG" | |
| else | |
| echo "Creating draft release for $TAG" | |
| gh release create "$TAG" --draft \ | |
| --title "$TAG" \ | |
| --notes "Automated draft – fill the changelog later." | |
| fi | |
| - name: Upload tarballs | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release upload "$TAG" dist/* --clobber | |
| gh release view "$TAG" --json assets --jq '.assets[].name' |