-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (74 loc) · 2.41 KB
/
release.yml
File metadata and controls
84 lines (74 loc) · 2.41 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
83
84
name: Release workflow
on:
workflow_dispatch:
inputs:
version:
type: string
required: true
description: 'Version number to release in X.Y.Z format'
dry_run:
type: boolean
default: true
description: 'Dry run'
pull_request:
types:
- closed
branches:
- 'main'
jobs:
release_workflow:
runs-on: ubuntu-latest
if: >
(github.event_name == 'workflow_dispatch') ||
(github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/'))
steps:
- name: Get Gitflow App token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.GITFLOW_APP_ID }}
private-key: ${{ secrets.GITFLOW_APP_KEY }}
- name: Gitflow action
id: gitflow-action
uses: hoangvvo/gitflow-workflow-action@0.3.7
with:
develop_branch: "develop"
main_branch: "main"
version: ${{ inputs.version }}
version_increment: ${{ contains(github.head_ref, 'hotfix/') && 'patch' || '' }}
dry_run: ${{ inputs.dry_run }}
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ steps.gitflow-action.outputs.release_branch || 'main' }}
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 'latest'
# Bumping version if we are in the 'create release PR mode'
- name: Bump version
if: ${{ steps.gitflow-action.outputs.release_branch }}
env:
VERSION: ${{ steps.gitflow-action.outputs.version }}
run: poetry version $VERSION
# Committing bumped version to the release branch
- name: Commit new version
if: ${{ steps.gitflow-action.outputs.release_branch }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Bump version to ${{ steps.gitflow-action.outputs.version }}"
# Building and publishing if we are in 'created new release mode'
- name: Build and publish package
if: ${{ !steps.gitflow-action.outputs.release_branch }}
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish --build