-
Notifications
You must be signed in to change notification settings - Fork 1
83 lines (72 loc) · 3.02 KB
/
Copy pathbump-version.yml
File metadata and controls
83 lines (72 loc) · 3.02 KB
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
name: Release
on:
push:
branches:
- main
jobs:
bump:
env:
RELEASE_REPOSITORY: pypi
RELEASE_PACKAGE_NAME: emnify-sdk
name: Bump and Release
permissions:
contents: write
# Prevent circular workflow run. Keyed on the commit message, not the pusher:
# the bump is pushed by the emnify-github-actions App (pusher name
# emnify-github-actions[bot], which does not match the old 'emnify-gha'
# check), and App pushes DO re-trigger workflows.
if: "!contains(github.event.head_commit.message, '[Automated] Version Bump')"
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ github.token }}
# Installation token for the emnify-github-actions App, which is on the
# bypass list for protected main and so can push the version bump. Replaces
# the expired EMNIFY_GITHUB_ACTIONS_TOKEN PAT.
- name: Retrieve application token
id: get_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.EMNIFY_GITHUB_ACTIONS_APP_ID }}
private-key: ${{ secrets.EMNIFY_GITHUB_ACTIONS_APP_PEM }}
- uses: actions/checkout@v4
with:
token: ${{ steps.get_token.outputs.token }}
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.2
with:
release_branches: master,main,feature/automated-release
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
- name: Apply Bump
id: bump
run: |
docker build . -f Dockerfile.dev -t emnify/python-sdk
docker run -v $(pwd):/sdk emnify/python-sdk bump2version patch --new-version=${{ steps.tag_version.outputs.new_version }} --list >> $GITHUB_ENV
cat > emnify/version.py << EOT
# THIS FILE IS GENERATED AUTOMATICALLY, DON'T CHANGE ITS CONTENT!!
EMNIFY_PACKAGE_VERSION="${{ steps.tag_version.outputs.new_version }}"
EOT
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: '[Automated] Version Bump from ${{ env.current_version }} to ${{ env.new_version }}'
- name: Release and Publish Package
env:
RELEASE_PYPI_TOKEN: ${{ secrets.PYPI_RELEASE_TOKEN }}
run: |
cat <<EOT >> .env
TWINE_REPOSITORY=${{env.RELEASE_REPOSITORY}}
TWINE_USERNAME=__token__
TWINE_PASSWORD=${RELEASE_PYPI_TOKEN}
PYPI_PACKAGE_NAME=${{env.RELEASE_PACKAGE_NAME}}
EOT
docker run --env-file=.env -v $(pwd):/sdk emnify/python-sdk python3 -m build
docker run --env-file=.env -v $(pwd):/sdk emnify/python-sdk python3 -m twine upload dist/*