s3dedup v1.3.1 #20
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: | |
| release: | |
| types: [created] | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| build-binaries: | |
| name: Build ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| artifact_name: s3dedup | |
| asset_name: s3dedup-linux-x86_64 | |
| - os: ubuntu-latest | |
| target: aarch64-unknown-linux-gnu | |
| artifact_name: s3dedup | |
| asset_name: s3dedup-linux-aarch64 | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| artifact_name: s3dedup | |
| asset_name: s3dedup-macos-x86_64 | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| artifact_name: s3dedup | |
| asset_name: s3dedup-macos-aarch64 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust stable | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install cross-compilation tools | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| - name: Configure linker for aarch64 | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| mkdir -p .cargo | |
| cat >> .cargo/config.toml << EOF | |
| [target.aarch64-unknown-linux-gnu] | |
| linker = "aarch64-linux-gnu-gcc" | |
| EOF | |
| - name: Build | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Strip binary | |
| if: matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-gnu' | |
| run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }} | |
| - name: Strip binary (aarch64) | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: aarch64-linux-gnu-strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }} | |
| - name: Upload binary to release | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ github.event.release.upload_url }} | |
| asset_path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} | |
| asset_name: ${{ matrix.asset_name }} | |
| asset_content_type: application/octet-stream | |
| build-docker: | |
| name: Build and push Docker image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # Determine if this is a prerelease (contains -dev, -alpha, -beta, -rc) | |
| if [[ "$VERSION" =~ -dev|-alpha|-beta|-rc ]]; then | |
| echo "is_prerelease=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_prerelease=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Generate Docker tags | |
| id: tags | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| IS_PRERELEASE="${{ steps.version.outputs.is_prerelease }}" | |
| # Always tag with version and latest-dev | |
| TAGS="ghcr.io/sio2project/s3dedup:$VERSION" | |
| TAGS="${TAGS}\nghcr.io/sio2project/s3dedup:latest-dev" | |
| # Stable releases also get :latest | |
| if [[ "$IS_PRERELEASE" == "false" ]]; then | |
| TAGS="${TAGS}\nghcr.io/sio2project/s3dedup:latest" | |
| fi | |
| echo "tags<<EOF" >> $GITHUB_OUTPUT | |
| echo -e "$TAGS" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile.cross | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.tags.outputs.tags }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |