diff --git a/.github/release-please/manifest.json b/.github/release-please/manifest.json index 3a327a03..69535c61 100644 --- a/.github/release-please/manifest.json +++ b/.github/release-please/manifest.json @@ -1,3 +1,3 @@ { - ".": "0.0.3" + ".": "0.2.4" } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a2b48405..8e44dded 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,8 +5,16 @@ on: inputs: tag: type: string - description: 'The tag to use for the Docker image' + description: 'The tag to use for the Docker image.' required: true + workflow_dispatch: + inputs: + prerelease_name: + description: "Suffix to use for manual pre-release." + required: false + type: string + default: "" + pull_request: jobs: @@ -30,93 +38,84 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 with: - ref: ${{ inputs.tag }} + ref: ${{ inputs.tag || '' }} - name: Install Rust uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable + rustflags: "" - name: Install target run: rustup target add ${{ matrix.arch }} - - name: Run cargo clean - run: cargo clean - - # ============================== - # Builds - # ============================== - - - name: Install cross v0.2.4 from source - env: - RUSTFLAGS: "" - run: | - cargo install cross --git https://github.com/cross-rs/cross --tag v0.2.4 + - name: Install cross v0.2.5 from source + run: cargo install cross --git https://github.com/cross-rs/cross --tag v0.2.5 - name: Build anvil-zksync for ${{ matrix.arch }} run: | - if [[ "${{ matrix.arch }}" == *"linux"* ]]; then - make build-static-${{ matrix.arch }} - else - make build-${{ matrix.arch }} - fi + [[ "${{ matrix.arch }}" == *"linux"* ]] && make build-static-${{ matrix.arch }} || make build-${{ matrix.arch }} - - name: Rename and move binary + - name: Pack anvil-zksync run: | - mkdir artifacts - strip target/${{ matrix.arch }}/release/anvil-zksync - mv target/${{ matrix.arch }}/release/anvil-zksync ./artifacts + tar -czf anvil-zksync-${{ inputs.tag || 'v0.0.0' }}-${{ matrix.arch }}.tar.gz \ + ./target/${{ matrix.arch }}/release/anvil-zksync - - name: Create artifacts - run: | - cd artifacts - tar -czf anvil-zksync-${{ inputs.tag }}-${{ matrix.arch }}.tar.gz anvil-zksync* - mv *tar.gz* .. - - # ======================================================================= - # Upload artifacts - # This is required to share artifacts between different jobs - # ======================================================================= - name: Upload artifact uses: actions/upload-artifact@v4 with: name: anvil-zksync-${{ matrix.arch }} - path: anvil-zksync-${{ inputs.tag }}-${{ matrix.arch }}.tar.gz - - - name: Binaries attestation - uses: actions/attest-build-provenance@v2 - with: - subject-path: ./artifacts/anvil-zksync - - draft-release: - name: draft release + path: | + anvil-zksync-${{ inputs.tag || 'v0.0.0' }}-${{ matrix.arch }}.tar.gz + ./target/${{ matrix.arch }}/release/anvil-zksync + + + upload-binaries: + name: Upload binaries + permissions: + contents: write + pull-requests: write + id-token: write + attestations: write needs: build runs-on: ubuntu-latest - env: - VERSION: ${{ needs.extract-version.outputs.VERSION }} steps: - name: Checkout sources uses: actions/checkout@v4 with: - ref: ${{ inputs.tag }} + ref: ${{ inputs.tag || '' }} + + - name: Define release name + id: release_tag + shell: 'bash -ex {0}' + run: | + [ ! -z "${{ inputs.tag }}" ] && TAG="${{ inputs.tag }}" \ + || TAG="$(git rev-parse --short HEAD)" + echo "tag=${TAG}" >> "${GITHUB_OUTPUT}" - # ============================== - # Download artifacts - # ============================== - name: Download artifacts uses: actions/download-artifact@v4 with: pattern: "anvil-zksync-*" - merge-multiple: 'false' - -# - name: Create release draft -# env: -# GITHUB_USER: ${{ github.repository_owner }} -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# run: | -# assets=() -# for asset in ./anvil-zksync-*.tar.gz*; do -# assets+=("$asset/$asset") -# done -# tag_name="${{ env.VERSION }}" -# gh release create "$tag_name" "${assets[@]}" --draft -F "-" -t "Release: $tag_name" + path: artifacts + + - name: Binaries attestation + uses: actions/attest-build-provenance@v2 + with: + subject-path: 'artifacts/**/anvil-zksync' + + - name: Update release-please release artifacts + if: ${{ inputs.tag != '' }} + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ inputs.tag }} + files: 'artifacts/**/anvil-zksync*.tar.gz' + + - name: Create release + if: ${{ inputs.tag == '' }} + uses: softprops/action-gh-release@v2 + with: + name: 'anvil-zksync ${{ inputs.prerelease_name}} ${{ steps.release_tag.outputs.tag }}' + tag_name: ${{ steps.release_tag.outputs.tag }} + prerelease: true + files: 'artifacts/**/anvil-zksync*.tar.gz' diff --git a/Cargo.toml b/Cargo.toml index 853c3080..856eba09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,10 @@ resolver = "2" [profile.dev] debug = 0 +[profile.release] +strip = "debuginfo" # Automatically strip symbols from the binary. +lto = "thin" # Enable link-time optimization. + [workspace.package] version = "0.2.4" # x-release-please-version edition = "2021" diff --git a/Dockerfile b/Dockerfile index 83356e8d..64cb014c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN cargo chef prepare --recipe-path recipe.json FROM chef AS builder COPY --from=planner /anvil-zksync/recipe.json recipe.json -# Build dependencies - this is the caching Docker layer! +# Build dependencies - this is the caching Docker layer RUN cargo chef cook --release --recipe-path recipe.json # Build application COPY . .