fix: make gha checks (docs, build, etc) triggered by main workflows #887
Workflow file for this run
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: Bump version, create release and deploy | ||
on: | ||
workflow-run: | ||
workflows: ["Build and test BSB", "Documentation", "Black", "Run isort", "Check public API"] | ||
branches: [main] | ||
types: [completed] | ||
jobs: | ||
isort: | ||
uses: ./.github/workflows/isort.yml | ||
black: | ||
uses: ./.github/workflows/black.yml | ||
build: | ||
uses: ./.github/workflows/build.yml | ||
docs: | ||
uses: ./.github/workflows/docs.yml | ||
api: | ||
uses: ./.github/workflows/api.yml | ||
bump: | ||
needs: [isort, black, build, docs, api] | ||
runs-on: ubuntu-latest | ||
outputs: | ||
tag: ${{ steps.semver.outputs.next }} | ||
old_tag: ${{ steps.semver.outputs.current }} | ||
steps: | ||
- name: Create Github token | ||
uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
app-id: ${{ vars.DBBS_APP_ID }} | ||
private-key: ${{ secrets.DBBS_APP_PRIVATE_KEY }} | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ steps.app-token.outputs.token }} | ||
- name: Get Next Version | ||
id: semver | ||
uses: ietf-tools/semver-action@v1 | ||
with: | ||
token: ${{ steps.app-token.outputs.token }} | ||
branch: main | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.11 | ||
- name: Bump version in Python project | ||
run: | | ||
pip install --upgrade pip bump-my-version | ||
oldv="${{ steps.semver.outputs.current }}" | ||
newv="${{steps.semver.outputs.next}}" | ||
# Bump the version, dropping the leading `v` with `${x:1}` | ||
bump-my-version replace --current-version=${oldv:1} --new-version=${newv:1} pyproject.toml | ||
- name: Commit & Push version change | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
branch: main | ||
commit_message: 'docs: bump version: ${{ steps.semver.outputs.current }} → ${{ steps.semver.outputs.next }} [skip-ci]' | ||
- name: Create tag | ||
uses: rickstaa/action-create-tag@v1 | ||
with: | ||
tag: ${{ steps.semver.outputs.next }} | ||
github_token: ${{ steps.app-token.outputs.token }} | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: bump | ||
steps: | ||
- name: Create Github token | ||
uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
app-id: ${{ vars.DBBS_APP_ID }} | ||
private-key: ${{ secrets.DBBS_APP_PRIVATE_KEY }} | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ steps.app-token.outputs.token }} | ||
- name: Pull commit of version change | ||
run: | | ||
git pull origin main | ||
- name: Update CHANGELOG | ||
id: changelog | ||
uses: requarks/changelog-action@v1 | ||
with: | ||
token: ${{ steps.app-token.outputs.token }} | ||
fromTag: ${{ needs.bump.outputs.tag }} | ||
toTag: ${{ needs.bump.outputs.old_tag }} | ||
- name: Create Release | ||
uses: ncipollo/[email protected] | ||
with: | ||
allowUpdates: true | ||
draft: false | ||
makeLatest: true | ||
tag: ${{ needs.bump.outputs.tag }} | ||
name: ${{ needs.bump.outputs.tag }} | ||
body: ${{ steps.changelog.outputs.changes }} | ||
token: ${{ steps.app-token.outputs.token }} | ||
- name: Commit CHANGELOG.md | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
branch: main | ||
commit_message: 'docs: update CHANGELOG.md for ${{ github.ref_name }} [skpi ci]' | ||
file_pattern: CHANGELOG.md | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: release | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.11 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install build twine | ||
- name: Build and publish | ||
env: | ||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
run: | | ||
python -m build | ||
twine upload --verbose --repository pypi dist/* | ||
deploy_ebrains: | ||
runs-on: ubuntu-latest | ||
needs: release | ||
environment: EBRAINS | ||
steps: | ||
- name: Mirror to EBRAINS Gitlab | ||
uses: wei/git-sync@v3 | ||
with: | ||
source_repo: dbbs-lab/bsb-core | ||
source_branch: main | ||
destination_repo: https://push:${{ secrets.EBRAINS_GITLAB_ACCESS_TOKEN }}@gitlab.ebrains.eu/robinde/bsb-core.git | ||
destination_branch: main |