Merge pull request #2925 from getzola/next #4
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*.*.*"] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| permissions: | |
| contents: read | |
| jobs: | |
| Release-Build: | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: read | |
| attestations: write | |
| id-token: write | |
| strategy: | |
| matrix: | |
| target: | |
| - x86_64-unknown-linux-gnu | |
| - x86_64-unknown-linux-musl | |
| - aarch64-unknown-linux-gnu | |
| - x86_64-pc-windows-msvc | |
| - x86_64-apple-darwin | |
| - aarch64-apple-darwin | |
| rustup_toolchain: [stable] | |
| include: | |
| - os: windows-2022 | |
| target: x86_64-pc-windows-msvc | |
| - os: ubuntu-22.04 | |
| target: x86_64-unknown-linux-gnu | |
| - os: ubuntu-22.04 | |
| target: x86_64-unknown-linux-musl | |
| - os: ubuntu-22.04-arm | |
| target: aarch64-unknown-linux-gnu | |
| - os: macos-15-intel | |
| target: x86_64-apple-darwin | |
| - os: macos-15 | |
| target: aarch64-apple-darwin | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: ${{ matrix.rustup_toolchain }} | |
| targets: ${{ matrix.target }} | |
| - name: Install Zig and cargo-zigbuild | |
| run: | | |
| curl -sSfL https://ziglang.org/download/0.14.0/zig-linux-x86_64-0.14.0.tar.xz | tar -xJf - | |
| echo "$PWD/zig-linux-x86_64-0.14.0" >> $GITHUB_PATH | |
| cargo install --locked cargo-zigbuild | |
| if: ${{ endsWith(matrix.target, 'linux-musl') }} | |
| - name: Cargo build | |
| run: cargo build --release --target ${{ matrix.target }} | |
| if: ${{ ! endsWith(matrix.target, 'linux-musl') }} | |
| - name: Cargo zigbuild | |
| run: cargo zigbuild --release --target ${{ matrix.target }} | |
| if: ${{ endsWith(matrix.target, 'linux-musl') }} | |
| - name: Show version | |
| run: ./target/${{ matrix.target }}/release/zola --version | |
| - name: Archive (UNIX) | |
| run: | | |
| mkdir -p artifacts | |
| cp -av target/${{ matrix.target }}/release/zola . | |
| OUTPUT_DIR="$(find target -path '*/zola-*/out' -type d)" | |
| cp -av "$OUTPUT_DIR"/* artifacts | |
| tar -czf ${{ github.event.repository.name }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz zola artifacts | |
| if: ${{ ! startsWith(matrix.os, 'windows') }} | |
| - name: Archive (Windows) | |
| run: | | |
| mkdir -p artifacts | |
| cp target/${{ matrix.target }}/release/zola.exe . | |
| Compress-Archive zola.exe ${{ github.event.repository.name }}-${{ github.ref_name }}-${{ matrix.target }}.zip | |
| if: ${{ startsWith(matrix.os, 'windows') }} | |
| - name: Attest Build Provenance | |
| uses: actions/attest-build-provenance@v2 | |
| continue-on-error: true | |
| with: | |
| subject-path: ${{ github.event.repository.name }}-${{ github.ref_name }}-${{ matrix.target }}.* | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ github.event.repository.name }}-${{ github.ref_name }}-${{ matrix.target }} | |
| path: ${{ github.event.repository.name }}-${{ github.ref_name }}-${{ matrix.target }}.* | |
| if-no-files-found: error | |
| retention-days: 7 | |
| Release: | |
| needs: [Release-Build] | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Ensure artifacts dir exists | |
| run: mkdir -p artifacts | |
| - name: Download Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Release | |
| uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 | |
| with: | |
| name: ${{ github.ref_name }} | |
| tag_name: ${{ github.ref_name }} | |
| generate_release_notes: true | |
| fail_on_unmatched_files: true | |
| body: | | |
| Welcome to this new release of Zola ${{ github.ref_name }}! | |
| All artifacts are signed with this repos identity using Sigstore. | |
| You can verify the signatures using the `GitHub` CLI. | |
| ```shell | |
| gh attestation verify --owner ${{ github.repository_owner }} <my-artifact> | |
| ``` | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| prerelease: ${{ contains(github.ref, '-pre') }} | |
| files: artifacts/* | |
| Release-Container-Image: | |
| needs: [Release] | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf | |
| - name: Setup Docker buildx | |
| uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| flavor: latest=false | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | |
| with: | |
| context: . | |
| push: true | |
| build-args: | | |
| USE_GH_RELEASE=true | |
| ZOLA_RELEASE_VERSION=${{ github.ref_name }} | |
| platforms: linux/amd64,linux/arm64 | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} |