forked from scc-digitalhub/digitalhub-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (87 loc) · 2.77 KB
/
release.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: Release on PyPI and GitHub
on:
workflow_dispatch:
inputs:
release-type:
description: "Release type"
required: true
default: "tag-num"
type: choice
options:
- major
- minor
- patch
- upgrade-beta
- new-beta-major
- new-beta-minor
- new-beta-patch
- final
skip-pypi:
description: "If true, skip publishing to PyPI"
default: false
type: boolean
jobs:
bumpver-pyproject:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.current-version.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install bumpver
run: python -m pip install bumpver
# Evaluate input and bumpver accordingly
- name: Execute script bumpver
run: ./.github/scripts/bump.sh ${{ inputs.release-type }}
# Commit modifications to pyproject.toml
- name: Commit changes
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git commit -a -m "bump: bumpver"
git push origin HEAD:main
# Store current version for later use
- name: Current version
id: current-version
run: |
ver=$(bumpver show -n --environ | grep CUR | awk '{gsub(/CURRENT_VERSION=/, ""); print}')
echo "version=${ver}" >> "$GITHUB_OUTPUT"
build-n-publish:
name: Build and publish
if: ${{ !inputs.skip-pypi }}
needs: bumpver-pyproject
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
# Build wheel to upload
- name: Install build and build a binary wheel
run: python -m pip install build && python -m build
# Publish to PyPI
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
tag-and-release:
name: Tag and release on Github
needs: [bumpver-pyproject]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.bumpver-pyproject.outputs.version }}
BETA: ${{ inputs.release-type == 'upgrade-beta' || startsWith(inputs.release-type, 'new-beta')}}
with:
name: ${{ env.VERSION }}
tag_name: ${{ env.VERSION }}
generate_release_notes: true
draft: false
prerelease: ${{ env.BETA }}