Skip to content

version bump

version bump #41

Workflow file for this run

# inspired by https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/release.yml
# and https://dzfrias.dev/blog/deploy-rust-cross-platform-github-actions
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
name: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get the release version tag
if: env.VERSION == ''
run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Get the release version from the tag
if: env.VERSION_CARGO == ''
run: echo "VERSION_CARGO=${VERSION:1}" >> $GITHUB_ENV
- name: Show the version
run: |
echo "version is: $VERSION and $VERSION_CARGO"
- name: Check that tag version and Cargo.toml version are the same
shell: bash
run: |
if ! grep -q "version = \"$VERSION_CARGO\"" rvimage/Cargo.toml; then
echo "version does not match Cargo.toml" >&2
exit 1
fi
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create $VERSION --draft --verify-tag --title $VERSION
outputs:
version: ${{ env.VERSION }}
build-release:
name: build-release
needs: ['create-release']
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- build: macos
os: macos-latest
target: aarch64-apple-darwin
- build: macos
os: macos-latest
target: x86_64-apple-darwin
- build: windows-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Build release binary Windows
if: matrix.os == 'windows-latest'
shell: powershell
run: |
cargo build --verbose --release --target-dir ${{ matrix.target }}
$bin="${{ matrix.target }}/release/rvimage.exe"
echo "BIN=$bin" >> $env:GITHUB_ENV
- name: Build release binary MacOS
shell: bash
if: matrix.os == 'macos-latest'
run: |
cargo build --verbose --release --target-dir ${{ matrix.target }}
bin=${{ matrix.target }}/release/rvimage
echo "BIN=$bin" >> $GITHUB_ENV
- name: Build archive
shell: bash
run: |
FOLDER="rvimage-${{ needs.create-release.outputs.version }}-${{ matrix.target }}"
mkdir "$FOLDER"
cp "$BIN" "$FOLDER"
cp {README.md,LICENSE} "$FOLDER"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a "$FOLDER.zip" "$FOLDER"
certutil -hashfile "$FOLDER.zip" SHA256 > "$FOLDER.zip.sha256"
echo "ASSET=$FOLDER.zip" >> $GITHUB_ENV
echo "ASSET_SUM=$FOLDER.zip.sha256" >> $GITHUB_ENV
else
tar -czf "$FOLDER.tar.gz" "$FOLDER"
shasum -a 256 "$FOLDER.tar.gz" > "$FOLDER.tar.gz.sha256"
echo "ASSET=$FOLDER.tar.gz" >> $GITHUB_ENV
echo "ASSET_SUM=$FOLDER.tar.gz.sha256" >> $GITHUB_ENV
fi
- name: Upload release archive
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
version="${{ needs.create-release.outputs.version }}"
gh release upload "$version" ${{ env.ASSET }} ${{ env.ASSET_SUM }}