bump version #36
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 | |
on: | |
# workflow_call: | |
# whenever a PR is closed against main | |
workflow_dispatch: | |
inputs: | |
bump_type: | |
type: choice | |
options: ['minor', 'major', 'patch'] | |
description: 'Bump version' | |
required: true | |
default: 'patch' | |
workflow_call: | |
inputs: | |
bump_type: | |
type: string | |
description: 'Bump version - minor, major or patch' | |
required: true | |
# pull_request: | |
# branches: | |
# - main | |
# types: | |
# - closed | |
jobs: | |
bump_package_version: | |
environment: | |
name: 'bump-version' | |
runs-on: ubuntu-latest | |
permissions: # Job-level permissions configuration starts here | |
contents: write # 'write' access to repository contents | |
actions: 'read' | |
steps: | |
- name: set bump type | |
id: set_bump_type | |
# if workflow_dispatch, use the 'inputs' context, otherwise set the bump type to 'patch' | |
run: | | |
if [ -n "${{ github.event.inputs.bump_type }}" ]; then | |
echo "BUMP_TYPE=${{ github.event.inputs.bump_type }}" >> "$GITHUB_ENV" | |
else | |
echo "BUMP_TYPE=patch" >> "$GITHUB_ENV" | |
fi | |
- name: Create GitHub App Token | |
uses: actions/create-github-app-token@31c86eb3b33c9b601a1f60f98dcbfd1d70f379b4 # v1 | |
# Create GitHub App Token to let us push changes to main | |
id: app-token | |
with: | |
app-id: ${{ vars.PUSH_APP_ID }} | |
private-key: ${{ secrets.PUSH_APP_SECRET }} | |
- name: check out code | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ steps.app-token.outputs.token }} | |
- name: Set up Python | |
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5 | |
with: | |
python-version: 3.12 | |
- name: install poetry | |
uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b # v1 | |
with: | |
version: 1.8.3 # pin the version as they keep changing their APIs | |
virtualenvs-create: false | |
virtualenvs-in-project: false | |
- name: Install dependencies | |
run: | | |
python -m venv venv | |
. venv/bin/activate | |
poetry install --without dev --no-interaction --sync | |
python -c "import os; print(os.environ['VIRTUAL_ENV'])" | |
- name: Bump version and build | |
run: | | |
poetry version ${{ env.BUMP_TYPE }} | |
version=$(poetry version | awk '{print $2}') | |
echo "VERSION=$version" >> $GITHUB_ENV | |
- name: commit updated version number | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add pyproject.toml | |
git commit -m "Bump version to ${{ env.VERSION }}" | |
- name: Push changes to main | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ steps.app-token.outputs.token }} | |
branch: ${{ github.ref }} | |
outputs: | |
package-version: ${{ env.VERSION }} | |