👷 Update release workflow #26
This file contains 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: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.sha }} | |
cancel-in-progress: true | |
jobs: | |
build-release: | |
name: build-release ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 5 | |
strategy: | |
matrix: | |
include: | |
- build: linux | |
os: ubuntu-20.04 | |
rust: stable | |
target: x86_64-unknown-linux-musl | |
- build: macos | |
os: macos-latest | |
rust: stable | |
target: x86_64-apple-darwin | |
- build: macos-arm64 | |
os: macos-latest | |
rust: stable | |
target: aarch64-apple-darwin | |
env: | |
RUST_BACKTRACE: full | |
TARGET_DIR: ./target | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Install packages (Ubuntu) | |
if: matrix.os == 'ubuntu-20.04' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y musl-tools | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ matrix.rust }} | |
profile: minimal | |
override: true | |
- name: Determine version changes | |
id: version_check | |
shell: bash | |
run: | | |
git fetch --tags | |
latest_version=$(git describe --tags --abbrev=0 | sed 's/^v//') | |
cargo_version=$(cargo pkgid | sed 's/.*#//') | |
if [ "$latest_version" != "$cargo_version" ]; then | |
echo "Version has changed to $cargo_version" | |
echo "version_changed=true" >> $GITHUB_OUTPUT | |
echo "NEW_VERSION=$cargo_version" >> $GITHUB_ENV | |
else | |
echo "Version has not changed" | |
echo "version_changed=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Skip if version has not changed | |
if: steps.version_check.outputs.version_changed != 'true' | |
run: | | |
echo "Version has not changed, skipping release" | |
exit 78 | |
- name: Build and Package | |
shell: bash | |
run: | | |
scripts/package.sh --target ${{ matrix.target }} | |
echo "ASSET=dist/flopha-${{ matrix.target }}.tar.gz" >> $GITHUB_ENV | |
- name: Upload release archive | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.NEW_VERSION }} | |
generate_release_notes: True | |
files: ${{ env.ASSET }} |