-
Notifications
You must be signed in to change notification settings - Fork 1
99 lines (89 loc) · 2.73 KB
/
Copy pathrelease.yml
File metadata and controls
99 lines (89 loc) · 2.73 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Release a version
on:
release:
types:
- published
jobs:
build:
name: Build sdist/wheel
uses: ./.github/workflows/build.yml
with:
artifact-name: pydiamond-dist
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
name: Distribute packages
steps:
- name: Retrieve packages
uses: actions/download-artifact@v6
with:
name: pydiamond-dist
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.12.4
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Upload to Github Release
uses: softprops/action-gh-release@v2.3.2
with:
files: |
dist/*
build-failure:
needs: build
if: failure()
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Delete release
run: gh release delete ${{ github.ref_name }} --yes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Delete tag
run: git push --delete origin ${{ github.ref_name }}
version-check:
runs-on: ubuntu-latest
outputs:
minor_major_release: ${{ steps.check.outputs.minor_major_release }}
steps:
- name: Verify minor/major release
id: check
run: |
import os
import re
version = "${{ github.ref_name }}"
if re.match(r"^v\d+\.\d+\.0$", version):
print("This is a minor/major release")
with open(os.environ["GITHUB_OUTPUT"], "a") as fp:
print("minor_major_release=true", file=fp)
else:
print("This is not a minor/major release")
shell: python
make-release-branch:
needs: [version-check, build]
if: ${{ success() && needs.version-check.outputs.minor_major_release == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup 'github-actions' user
uses: ./.github/actions/setup-github-actions-bot-user
- name: Get release branch name
run: echo "RELEASE_BRANCH_NAME=release/${GITHUB_REF_NAME%.0}.x" >> $GITHUB_ENV
- name: Create release branch
run: git checkout -b $RELEASE_BRANCH_NAME ${{ github.ref_name }}
- name: Rewrite .bumpversion.cfg
continue-on-error: true
run: |
python ./.github/scripts/rewrite_bumpversion_cfg.py ./.bumpversion.cfg
git add .bumpversion.cfg
git commit -m "[RELEASE] Updated .bumpversion.cfg"
- name: Push created branch
run: git push origin $RELEASE_BRANCH_NAME