Skip to content

Release TinyStan

Release TinyStan #7

Workflow file for this run

name: Release TinyStan
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 TinyStan
runs-on: ubuntu-latest
permissions:
contents: write
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@v1
- name: Update version numbers
if: ${{ !inputs.is_rerun }}
run: |
sed -i 's/Version:.*/Version: ${{ inputs.new_version }}/' clients/R/DESCRIPTION
sed -i 's/version = .*/version = "${{ inputs.new_version }}"/' clients/julia/Project.toml
sed -i 's/__version__ = .*/__version__ = "${{ inputs.new_version }}"/' clients/python/tinystan/__version.py
sed -i 's/#define TINYSTAN_MAJOR .*/#define TINYSTAN_MAJOR '"$(echo ${{ inputs.new_version }} | cut -d. -f1)"'/' src/version.hpp
sed -i 's/#define TINYSTAN_MINOR .*/#define TINYSTAN_MINOR '"$(echo ${{ inputs.new_version }} | cut -d. -f2)"'/' src/version.hpp
sed -i 's/#define TINYSTAN_PATCH .*/#define TINYSTAN_PATCH '"$(echo ${{ inputs.new_version }} | cut -d. -f3)"'/' src/version.hpp
- name: Create tarball
run: |
tar --exclude-vcs --exclude='clients' -chzvf tinystan-${{ inputs.new_version }}.tar.gz --transform 's,^,tinystan-${{ inputs.new_version }}/,' *
# Note: because of the order of operations here, the Julia package inside the tarball can never point to itself.
- name: Update Julia artifact
if: ${{ !inputs.is_rerun }}
run: |
julia ./clients/julia/updateArtifacts.jl tinystan-${{ inputs.new_version }}.tar.gz "v${{ 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 clients/python/
python -m build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: |
clients/python/dist/*.whl
tinystan-*.tar.gz
- name: Create release
if: ${{ !inputs.is_rerun }}
uses: ncipollo/release-action@v1
with:
artifacts: "tinystan-*.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: clients/python/dist/
# skip_existing: true
# - name: Create JuliaRegistration comment
# if: ${{ !inputs.dry_run }}
# uses: peter-evans/commit-comment@v3
# with:
# sha: ${{ steps.commit.outputs.sha }}
# body: |
# @JuliaRegistrator register subdir=clients/julia