name: Release on: release: types: [ created ] env: CARGO_TERM_COLOR: always jobs: build-binary: strategy: matrix: include: - name: Linux 64-bit file-name: linux_amd64 target: x86_64-unknown-linux-gnu host: ubuntu-latest use-cross: true - name: Linux 32-bit file-name: linux_386 target: i686-unknown-linux-gnu host: ubuntu-latest use-cross: true - name: Linux ARM 64-bit file-name: linux_aarch64 target: aarch64-unknown-linux-gnu host: ubuntu-latest use-cross: true - name: macOS file-name: darwin_amd64 target: x86_64-apple-darwin host: macos-11 use-cross: false - name: macOS Apple Silicon file-name: darwin_aarch64 target: aarch64-apple-darwin host: macos-11 use-cross: false runs-on: ${{ matrix.host }} steps: - name: Checkout uses: actions/checkout@v2 - name: Select Rust toolchain uses: actions-rs/toolchain@v1 with: toolchain: stable override: true target: ${{ matrix.target }} - name: Use cache for Rust dependencies uses: Swatinem/rust-cache@v1 - name: Build uses: actions-rs/cargo@v1 with: command: build args: --release --target ${{ matrix.target }} use-cross: ${{ matrix.use-cross }} - name: Rename binary run: mv target/${{ matrix.target }}/release/reshape ./reshape-${{ matrix.file-name }} - name: Upload binary to release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh release upload ${GITHUB_REF##*/} "reshape-${{ matrix.file-name }}#${{ matrix.name }}" --clobber publish-docker: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Log in to Docker env: DOCKER_PASSWORD: ${{ secrets.DOCKER_ACCESS_TOKEN }} run: | docker login -u ${{ secrets.DOCKER_USER }} -p $DOCKER_PASSWORD - name: Build Docker image # GITHUB_REF is formatted as: refs/tags/v0.0.1 # The shell expansion used below will remove everything up to the version number, leaving 0.0.1 run: docker build . --tag ${{ secrets.DOCKER_USER }}/reshape:${GITHUB_REF##*/v} --tag ${{ secrets.DOCKER_USER }}/reshape:latest - name: Push Docker image run: docker push --all-tags ${{ secrets.DOCKER_USER }}/reshape publish-crate: runs-on: ubuntu-latest needs: ["build-binary", "publish-docker"] steps: - name: Checkout uses: actions/checkout@v2 - name: Select Rust toolchain uses: actions-rs/toolchain@v1 with: toolchain: stable - name: Publish to crates.io uses: actions-rs/cargo@v1 with: command: publish env: CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}