-
Notifications
You must be signed in to change notification settings - Fork 1
99 lines (87 loc) · 2.96 KB
/
deploy_bump_version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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@v1 # 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@v4 # v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Set up Python
uses: actions/setup-python@v5 # v5
with:
python-version: 3.12
- name: install poetry
uses: snok/install-poetry@v1 # 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 }}