chore: Release #8
Workflow file for this run
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: | |
tags: | |
- 'v*' | |
jobs: | |
# Allow our jobs to block on validation steps | |
validation_rust: | |
uses: ./.github/workflows/validation-rust.yaml | |
validation_py: | |
uses: ./.github/workflows/validation-python.yaml | |
rust_release: | |
name: "build & deploy ${{ matrix.build }} binaries" | |
needs: [validation_rust, validation_py] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- build: linux | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
# target: x86_64-unknown-linux-musl | |
extension: '' | |
# Unsuccessful compilation; try on local | |
# - build: linux-arm | |
# os: ubuntu-latest | |
# target: arm-unknown-linux-gnueabihf | |
# extension: '' | |
- build: macos | |
os: macos-latest | |
target: x86_64-apple-darwin | |
extension: '' | |
- build: windows-msvc | |
os: windows-latest | |
target: x86_64-pc-windows-msvc | |
extension: .exe | |
env: | |
CARGO: cargo | |
TARGET_DIR: ./target | |
TARGET_FLAGS: "" | |
steps: | |
# Retreive git files | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- uses: Swatinem/rust-cache@v2 | |
# Debugging aid | |
- name: Show commands | |
run: | | |
echo pwd: | |
pwd | |
echo ls: | |
ls | |
echo "cargo command is: ${{ env.CARGO }}" | |
echo "target flag is: ${{ env.TARGET_FLAGS }}" | |
echo "target dir is: ${{ env.TARGET_DIR }}" | |
# Perform build | |
- name: Build binary | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
# We only want to build zspell-cli, not plain zspell or zspell-py (does not support cdylib) | |
args: --package zspell-cli --release --verbose --target ${{ matrix.target }} | |
- name: Show output | |
run: | | |
ls target | |
ls "target/${{ matrix.target }}" | |
ls "target/${{ matrix.target }}/release" | |
# Create .zip or .tar.gz file | |
- name: Build archive | |
shell: bash | |
run: | | |
echo '\nWorking directory:' && pwd | |
echo '\nls:' && ls | |
# outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")" | |
# outdir=target/release/${{ steps.get_repository_name.outputs.REPOSITORY_NAME }}${{ matrix.extension }} | |
# Find the output directory with the latest timestamp | |
cargo_outdir="$(find "${{ env.TARGET_DIR }}" -name zspell-stamp -print0 | xargs -0 ls -t | head -n1 | xargs dirname)" | |
ref_name=${GITHUB_REF##*/} | |
# Remove leading 'v' for use where needed | |
ref_name_stripped=$(echo $ref_name | perl -0pe 's/^v//') | |
echo "\nRef name: \"$ref_name\"" | |
echo "\nRef name stripped: \"$ref_name_stripped\"" | |
staging="zspell-$ref_name-${{ matrix.target }}" | |
mkdir -p "$staging"/{completion,doc} | |
# Remove the "unreleased" section from our changelog | |
perl -0777 -i -pe "s/(<\!-- next-header -->.*## \[Unreleased\].*?\n)(?=## |<\!--)//gms" CHANGELOG.md | |
cp {README.md,LICENSE} "$staging/" | |
cp CHANGELOG.md "$staging/doc/" | |
cp "$cargo_outdir"/zspell.1 "$staging/doc" | |
cp "$cargo_outdir"/{_zspell,_zspell.ps1,zspell.bash,zspell.elv,zspell.fish} "$staging/completion" | |
# Build RNOTES.md, which we will use for our Github release (not shipped in zip) | |
# Select the release notes from our latest version only | |
perl -0777 -ne "print /(## \[$ref_name_stripped\].*?\n)(?=\n*^(?:## |<\!--))/gms" CHANGELOG.md > RNOTES.md | |
# Select the diff URL for this version only | |
perl -0777 -ne "print /\n\[$ref_name_stripped\]:.*?\n/gms" CHANGELOG.md >> RNOTES.md | |
echo "Release notes:" && cat RNOTES.md | |
if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
cp "target/${{ matrix.target }}/release/zspell.exe" "$staging/" | |
7z a "$staging.zip" "$staging" | |
echo "ASSET=$staging.zip" >> $GITHUB_ENV | |
else | |
cp "target/${{ matrix.target }}/release/zspell" "$staging/" | |
tar czf "$staging.tar.gz" "$staging" | |
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV | |
fi | |
# Upload to github | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_REPOSITORY: pluots/zspell | |
with: | |
body_path: RNOTES.md | |
# note you'll typically need to create a personal access token | |
# with permissions to create releases in the other repo | |
token: ${{ secrets.GITHUB_TOKEN }} | |
files: | | |
${{ env.ASSET }} | |
linux_wheels: | |
runs-on: ubuntu-latest | |
needs: [validation_rust, validation_py] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: build libc wheels | |
uses: messense/maturin-action@v1 | |
with: | |
manylinux: auto | |
command: build | |
# container default is manylinux | |
args: --release -o dist -i 3.7 3.8 3.9 3.10 3.11 3.12 --manifest-path zspell-py/Cargo.toml | |
- name: build musl wheels | |
uses: messense/maturin-action@v1 | |
with: | |
target: x86_64-unknown-linux-musl | |
manylinux: musllinux_1_1 | |
command: build | |
args: --release -o dist -i 3.7 3.8 3.9 3.10 3.11 3.12 --manifest-path zspell-py/Cargo.toml | |
- name: upload wheels | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wheels | |
path: dist | |
windows_wheels: | |
runs-on: windows-latest | |
needs: [validation_rust, validation_py] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: messense/maturin-action@v1 | |
with: | |
command: build | |
# FIXME: python 3.12 not yet available on windows runners | |
args: --release -o dist -i 3.7 3.8 3.9 3.10 3.11 --manifest-path zspell-py/Cargo.toml | |
- name: upload wheels | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wheels | |
path: dist | |
macos_wheels: | |
runs-on: macos-latest | |
needs: [validation_rust, validation_py] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: messense/maturin-action@v1 | |
with: | |
command: build | |
args: --release -o dist -i 3.7 3.8 3.9 3.10 3.11 3.12 --universal2 --manifest-path zspell-py/Cargo.toml | |
- name: upload wheels | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wheels | |
path: dist | |
release_all_wheels: | |
name: Release wheels | |
runs-on: ubuntu-latest | |
needs: [linux_wheels, macos_wheels, windows_wheels] | |
steps: | |
- uses: actions/download-artifact@v2 | |
with: | |
name: wheels | |
- name: Publish to PyPI | |
uses: messense/maturin-action@v1 | |
env: | |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | |
with: | |
command: upload | |
args: --skip-existing * | |
deploy_book: | |
runs-on: ubuntu-latest | |
needs: [validation_rust, validation_py] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install mdbook | |
run: | | |
mkdir mdbook | |
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.14/mdbook-v0.4.14-x86_64-unknown-linux-gnu.tar.gz \ | |
| tar -xz --directory=./mdbook | |
echo `pwd`/mdbook >> $GITHUB_PATH | |
- name: Deploy GitHub Pages | |
run: | | |
# This assumes your book is in the root of your repository. | |
# Just add a `cd` here if you need to change to another directory. | |
mdbook build | |
git worktree add gh-pages | |
git config user.name "Deploy from CI" | |
git config user.email "" | |
cd gh-pages | |
# Delete the ref to avoid keeping history. | |
git update-ref -d refs/heads/gh-pages | |
rm -rf * | |
mv ../book/* . | |
git add . | |
git commit -m "Deploy $GITHUB_SHA to gh-pages" | |
git push --force --set-upstream origin gh-pages |