Release BridgeStan #17
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 | |
outputs: | |
sha: ${{ steps.commit.outputs.sha }} | |
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: 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 | |
publish: | |
name: Publish BridgeStan | |
if: ${{ !inputs.dry_run }} | |
runs-on: ubuntu-latest | |
needs: release | |
environment: publishing | |
permissions: | |
id-token: write | |
steps: | |
- name: Check out github | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Download release artifacts | |
uses: actions/download-artifact@v4 | |
- name: Publish on PyPI | |
uses: pypa/gh-action-pypi-publish@v1.12.2 | |
with: | |
packages-dir: python/dist/ | |
skip-existing: true | |
- name: Publish on crates.io | |
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: ${{ needs.release.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 |