Semantic Release #11
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: Semantic Release | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
concurrency: release | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- name: Check out the code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.PAT_TOKEN }} | |
- name: Install Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.8" | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- name: Install Dependencies | |
run: | | |
pip install maturin | |
pip install python-semantic-release toml | |
- name: Python Semantic Release | |
env: | |
GH_TOKEN: ${{ secrets.PAT_TOKEN }} | |
id: release | |
uses: python-semantic-release/[email protected] | |
with: | |
github_token: ${{ secrets.PAT_TOKEN }} | |
- name: Update Versions | |
if: steps.release.outputs.released == 'true' | |
run: | | |
NEW_VERSION="${{ steps.release.outputs.version }}" | |
sed -i "s/^version = .*/version = \"$NEW_VERSION\"/" pyproject.toml | |
sed -i "s/^version = .*/version = \"$NEW_VERSION\"/" Cargo.toml | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add pyproject.toml Cargo.toml | |
git commit -m "chore: update version to $NEW_VERSION [skip ci]" | |
git push origin HEAD:master | |
- name: Build and Publish with Maturin | |
if: steps.release.outputs.released == 'true' | |
env: | |
MATURIN_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
maturin build --release | |
maturin publish --username __token__ --password $MATURIN_PASSWORD |