Skip to content

release

release #12

Workflow file for this run

# inspired by https://github.com/shssoichiro/oxipng/blob/15ecc9ed00199f1fbfe0989d67a43ff3e6faff6a/.github/workflows/deploy.yml
name: release
# on:
# push:
# tags:
# - 'v*.*.*'
on:
workflow_run:
workflows: ["build"]
branches: [main]
types:
- completed
permissions:
actions: read
contents: write
jobs:
release:
name: release
runs-on: ubuntu-latest
# 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
env:
PROJECT_NAME: autocrap
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: get version
id: meta
run: |
version=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "'"$PROJECT_NAME"'").version')
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: retrieve ${{ matrix.target }} binary
uses: dawidd6/action-download-artifact@v6
with:
workflow: build.yml
commit: ${{ env.GITHUB_SHA }}
name: ${{ env.PROJECT_NAME }}-${{ matrix.target }}
path: target
- name: build archives
working-directory: target
run: |
echo "PROJECT_NAME=$PROJECT_NAME"
echo 'version=${{ steps.meta.outputs.version }}'
echo 'target=${{ matrix.target }}'
ARCHIVE_NAME='${{ env.PROJECT_NAME }}-${{ steps.meta.outputs.version }}-${{ matrix.target }}'
echo "ARCHIVE_NAME=$ARCHIVE_NAME"
mkdir "$ARCHIVE_NAME"
case '${{ matrix.target }}' in
*-windows-*)
cp -a "${PROJECT_NAME}.exe" "$ARCHIVE_NAME"
zip "${ARCHIVE_NAME}.zip" "$ARCHIVE_NAME"/*
;;
*)
cp -a "$PROJECT_NAME" "$ARCHIVE_NAME"
# fix permissions https://github.com/actions/toolkit/issues/1722
chmod ugo+x "$ARCHIVE_NAME"/"$PROJECT_NAME"
tar czvf "${ARCHIVE_NAME}.tar.gz" "$ARCHIVE_NAME"/*
;;
esac
- name: create release
uses: softprops/action-gh-release@v1
with:
name: v${{ steps.meta.outputs.version }}
# body_path: RELEASE_NOTES.txt
files: |
target/*.zip
target/*.tar.gz