Release BridgeStan #16
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 BridgeStan | |
on: | |
workflow_dispatch: | |
inputs: | |
new_version: | |
description: 'New version, for example: 1.1.0' | |
required: true | |
is_rerun: | |
type: boolean | |
description: Set to true if this version has already been 'released', e.g. to only re-run PyPI and Julia release steps | |
dry_run: | |
type: boolean | |
description: Set to true to avoid PyPI and Julia release steps | |
default: false | |
jobs: | |
release: | |
name: Release BridgeStan | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out github | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Set up Julia | |
uses: julia-actions/setup-julia@v2 | |
- name: Install LLVM and Clang | |
uses: KyleMayes/install-llvm-action@v2 | |
with: | |
version: "15.0" | |
directory: ${{ runner.temp }}/llvm | |
- name: Update version numbers | |
if: ${{ !inputs.is_rerun }} | |
run: | | |
sed -i 's/Version:.*/Version: ${{ inputs.new_version }}/' R/DESCRIPTION | |
sed -i 's/version = .*/version = "${{ inputs.new_version }}"/' julia/Project.toml | |
sed -i 's/__version__ = .*/__version__ = "${{ inputs.new_version }}"/' python/bridgestan/__version.py | |
sed -i 's/^version = .*/version = "${{ inputs.new_version }}"/' rust/Cargo.toml | |
sed -i 's/#define BRIDGESTAN_MAJOR .*/#define BRIDGESTAN_MAJOR '"$(echo ${{ inputs.new_version }} | cut -d. -f1)"'/' src/version.hpp | |
sed -i 's/#define BRIDGESTAN_MINOR .*/#define BRIDGESTAN_MINOR '"$(echo ${{ inputs.new_version }} | cut -d. -f2)"'/' src/version.hpp | |
sed -i 's/#define BRIDGESTAN_PATCH .*/#define BRIDGESTAN_PATCH '"$(echo ${{ inputs.new_version }} | cut -d. -f3)"'/' src/version.hpp | |
cd docs/ | |
python add_version.py "v${{ inputs.new_version }}" | |
- name: Create tarball | |
run: | | |
tar --exclude-vcs --hard-dereference -chzvf bridgestan-${{ inputs.new_version }}.tar.gz --transform 's,^,bridgestan-${{ inputs.new_version }}/,' * | |
- name: Setup git identity | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
- name: Create commit | |
id: commit | |
run: | | |
git commit -am "Release ${{ inputs.new_version }}: updating version numbers" || true | |
git push origin main | |
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
- name: Build Python package wheels | |
run: | | |
pip install wheel build | |
cd python/ | |
python -m build | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-artifacts | |
path: | | |
python/dist/*.whl | |
bridgestan-*.tar.gz | |
- name: Create release | |
if: ${{ !inputs.is_rerun }} | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "bridgestan-*.tar.gz,python/dist/*" | |
tag: "v${{ inputs.new_version }}" | |
commit: main | |
draft: true | |
generateReleaseNotes: true | |
allowUpdates: true | |
replacesArtifacts: true | |
skipIfReleaseExists: true | |
- name: Upload PyPI wheels | |
if: ${{ !inputs.dry_run }} | |
uses: pypa/[email protected] | |
with: | |
password: ${{ secrets.PYPI_TOKEN }} | |
packages_dir: python/dist/ | |
skip_existing: true | |
- name: Publish Rust crate | |
if: ${{ !inputs.dry_run }} | |
run: | | |
cd rust/ | |
cargo publish --token ${CRATES_TOKEN} | |
env: | |
# clang is necessary unless we want to do --no-verify | |
LIBCLANG_PATH: ${{ runner.temp }}/llvm/lib | |
LLVM_CONFIG_PATH: ${{ runner.temp }}/llvm/bin/llvm-config | |
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} | |
- name: Create JuliaRegistration comment | |
if: ${{ !inputs.dry_run }} | |
uses: peter-evans/commit-comment@v3 | |
with: | |
sha: ${{ steps.commit.outputs.sha }} | |
body: | | |
@JuliaRegistrator register subdir=julia | |
docs: | |
name: Build release docs | |
needs: release | |
uses: roualdes/bridgestan/.github/workflows/docs.yaml@main | |
with: | |
version: "v${{ inputs.new_version }}" | |
secrets: inherit |