Skip to content

Release

Release #10

Workflow file for this run

name: Release
on:
push:
tags:
- v*
jobs:
release:
permissions:
contents: write
name: Release ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: x86_64-pc-windows-gnu
- os: macos-latest
target: x86_64-apple-darwin
steps:
- uses: actions/checkout@master
- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
target: x86_64-pc-windows-gnu
toolchain: stable
- name: Install windows dependencies
if: matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-pc-windows-gnu'
run: |
sudo apt-get update
sudo apt-get -y install gcc-mingw-w64-x86-64 gcc-mingw-w64-i686
- name: Compile
id: compile
run: |
set -x
cargo build --all --release --target=${TARGET}
OUTPUT_DIR="built/output"
mkdir -p "$OUTPUT_DIR"
echo "BUILT_ARCHIVES=$OUTPUT_DIR" >> $GITHUB_OUTPUT
BINARIES=$(cargo read-manifest | jq -r ".targets[] | select(.kind[] | contains(\"bin\")) | .name")
for BIN in $BINARIES; do
ARCHIVE=$BIN\_${TARGET}.tar.gz
BIN_PATH=target/${TARGET}/release/$BIN
if [ ${TARGET} = 'x86_64-pc-windows-gnu' ]
then
BIN_PATH=$BIN_PATH.exe
fi
strip $BIN_PATH;
ARTIFACTS_FOLDER="${GITHUB_REPOSITORY#*/}_${GITHUB_REF_NAME}"
mkdir $ARTIFACTS_FOLDER
cp -r $BIN_PATH README.md LICENSE $ARTIFACTS_FOLDER
tar -caf $ARCHIVE $ARTIFACTS_FOLDER/*
mv $ARCHIVE $OUTPUT_DIR
done
env:
TARGET: ${{ matrix.target }}
- name: Name Release
run: echo "RELEASE_NAME=${GITHUB_REPOSITORY#*/} ${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
generate_release_notes: true
name: ${{ env.RELEASE_NAME }}
files: |
${{ steps.compile.outputs.BUILT_ARCHIVES }}/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-crate:
name: Publish to crates.io
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- run: cargo publish --token ${CRATES_TOKEN}
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
publish-npm:
name: Publish to npmjs.com
runs-on: ubuntu-latest
needs: release
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- uses: pnpm/action-setup@v2
with:
version: 8.6.6
run_install: |
- recursive: true
args: [--frozen-lockfile]
- run: pnpm publish --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}