name: deploy on: push: tags: - 'v*.*.*' permissions: actions: read contents: write jobs: deploy: name: Deploy release runs-on: ubuntu-latest timeout-minutes: 30 # Prevent job from running on forks if: ${{ !github.event.repository.fork }} strategy: matrix: target: - x86_64-unknown-linux-gnu - x86_64-unknown-linux-musl - aarch64-unknown-linux-gnu - aarch64-unknown-linux-musl - x86_64-pc-windows-msvc - i686-pc-windows-msvc - x86_64-apple-darwin - aarch64-apple-darwin steps: - name: Checkout source uses: actions/checkout@v4 - name: Get the Oxipng version id: oxipngMeta run: echo "version=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "oxipng").version')" >> "$GITHUB_OUTPUT" - name: Retrieve ${{ matrix.target }} binary uses: dawidd6/action-download-artifact@v3 with: workflow: oxipng.yml commit: ${{ env.GITHUB_SHA }} name: Oxipng binary (${{ matrix.target }}) path: target - name: Generate up to date manual run: scripts/manual.sh - name: Build archives working-directory: target run: | ARCHIVE_NAME="oxipng-${{ steps.oxipngMeta.outputs.version }}-${{ matrix.target }}" mkdir "$ARCHIVE_NAME" cp ../CHANGELOG.md ../README.md ../MANUAL.txt "$ARCHIVE_NAME" case '${{ matrix.target }}' in *-windows-*) cp ../LICENSE "$ARCHIVE_NAME/LICENSE.txt" cp oxipng.exe "$ARCHIVE_NAME" zip "${ARCHIVE_NAME}.zip" "$ARCHIVE_NAME"/*;; *) cp ../LICENSE "$ARCHIVE_NAME" cp oxipng "$ARCHIVE_NAME" # Execute permissions are not stored in artifact files, # so make the binary world-executable to meet user # expectations set by preceding releases. # Related issue: # https://github.com/shssoichiro/oxipng/issues/575 chmod ugo+x "$ARCHIVE_NAME"/oxipng tar -vczf "${ARCHIVE_NAME}.tar.gz" "$ARCHIVE_NAME"/*;; esac - name: Set up Ubuntu multiarch if: matrix.target == 'aarch64-unknown-linux-gnu' run: | readonly DISTRO_CODENAME=jammy sudo dpkg --add-architecture arm64 sudo sed -i "s/^deb http/deb [arch=$(dpkg-architecture -q DEB_HOST_ARCH)] http/" /etc/apt/sources.list sudo sed -i "s/^deb mirror/deb [arch=$(dpkg-architecture -q DEB_HOST_ARCH)] mirror/" /etc/apt/sources.list for suite in '' '-updates' '-backports' '-security'; do echo "deb [arch=arm64] http://ports.ubuntu.com/ $DISTRO_CODENAME$suite main universe multiverse" | \ sudo tee -a /etc/apt/sources.list >/dev/null done - name: Install QEMU and AArch64 cross compiler if: matrix.target == 'aarch64-unknown-linux-gnu' run: | sudo apt-get -yq update # libc6 must be present to run executables dynamically linked # against glibc for the target architecture sudo apt-get -yq install qemu-user gcc-aarch64-linux-gnu libc6:arm64 - name: Build deb archives if: endsWith(matrix.target, '-linux-gnu') run: | mkdir -p "target/${{ matrix.target }}/release" mv target/oxipng "target/${{ matrix.target }}/release" cargo install --locked cargo-deb cargo deb --target "${{ matrix.target }}" --no-build --no-strip - name: Create release notes run: tail -n +2 CHANGELOG.md | sed -e '/^$/,$d' > RELEASE_NOTES.txt - name: Create release uses: softprops/action-gh-release@v2 with: name: v${{ steps.oxipngMeta.outputs.version }} body_path: RELEASE_NOTES.txt files: | target/*.zip target/*.tar.gz target/${{ matrix.target }}/debian/*.deb