Skip to content

CI: create release

CI: create release #1

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:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
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: echo "version=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == \"$PROJECT_NAME\").version')"
>> "$GITHUB_OUTPUT"
- name: retrieve ${{ matrix.target }} binary
uses: dawidd6/action-download-artifact@v2
with:
workflow: build.yml
commit: ${{ env.GITHUB_SHA }}
name: ${{ env.PROJECT_NAME }} binary (${{ matrix.target }})
path: target
- name: build archives
working-directory: target
run: |
ls -alpR
ARCHIVE_NAME=${{ env.PROJECT_NAME }}-${{ steps.meta.outputs.version }}-${{ matrix.target }}"
mkdir "$ARCHIVE_NAME"
case '${{ matrix.target }}' in
*-windows-*)
cp "${PROJECT_NAME}.exe" "$ARCHIVE_NAME"
zip "${ARCHIVE_NAME}.zip" "$ARCHIVE_NAME"/*
;;
*)
cp "$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