release #27
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: | |
workflow_dispatch: | |
jobs: | |
cd: | |
permissions: | |
id-token: write | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Check-out repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.sha }} | |
- name: Install dependencies | |
run: | | |
python3 -m pip install --upgrade pip | |
python3 -m pip install --upgrade build setuptools setuptools_scm | |
- name: Setup | Force correct release branch on workflow sha | |
run: | | |
git checkout -B ${{ github.ref_name }} ${{ github.sha }} | |
- name: Verify dynamic version | |
run: python -m setuptools_scm | |
- name: Use Python Semantic Release to prepare release | |
id: release | |
uses: python-semantic-release/[email protected] | |
with: | |
github_token: ${{ secrets.QUANDA_ADMIN }} | |
changelog: true | |
tag: true | |
commit: false | |
- name: Build package | |
run: python3 -m build | |
- name: Publish to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
verbose: true | |
- name: Test install from TestPyPI | |
run: | | |
python -m pip install --index-url https://test.pypi.org/simple/ --no-deps quanda | |
- name: Check git version tag | |
run: git describe --tags --abbrev=0 | |
- name: Push changes to a new branch and create a PR | |
run: | | |
# Create a new branch from main | |
git checkout -b version-bump-${{ steps.release.outputs.tag }} | |
# Add the changes made by semantic-release (version update and changelog) | |
git add CHANGELOG.md | |
# Commit the changes (version bump and changelog update) | |
git commit -m "chore: Update changelog after version bump ${{ steps.release.outputs.tag }}" | |
# Push changes to the new branch | |
git push origin version-bump-${{ steps.release.outputs.tag }} | |
# Create a pull request using GitHub CLI (gh) | |
gh pr create --base main --head version-bump-${{ steps.release.outputs.tag }} --title "chore: Update changelog after version bump ${{ steps.release.outputs.tag }}" --body "Automated changelog update." | |
env: | |
GITHUB_TOKEN: ${{ secrets.QUANDA_ADMIN }} | |
- name: Merge the Pull Request | |
run: | | |
# Find the PR number for the created branch | |
PR_NUMBER=$(gh pr list --state open --head version-bump-${{ steps.release.outputs.tag }} --json number --jq '.[0].number') | |
# Merge the PR | |
gh pr merge $PR_NUMBER --merge --admin | |
env: | |
GITHUB_TOKEN: ${{ secrets.QUANDA_ADMIN }} |