-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
161 lines (152 loc) · 5.23 KB
/
action.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: "Pycord Library Release"
description: "Release a new package version for pycord"
branding:
color: "green"
icon: "upload-cloud"
inputs:
repository:
description: "The repository"
required: false
default: "Pycord-Development/pycord"
ref:
description: "The ref"
required: false
default: "master"
python-version:
description: "The python-version"
required: true
default: "3.12"
github-token:
description: "The GitHub token"
required: true
pypi-username:
description: "The PyPi token"
required: false
default: "__token__"
pypi-package:
description: "The PyPi package"
required: false
default: "py-cord"
pypi-token:
description: "The PyPi token"
required: true
release-requirements:
description: "The release requirements file"
required: false
default: "requirements/_release.txt"
version-branch-name:
description: "The version branch name"
required: true
version:
description: "The version to release"
required: true
is-rc:
description: "Whether to release as rc"
required: false
default: "false"
outputs:
gh-release:
description: "The GitHub Release url"
value: ${{ runs.steps.gh-release.outputs.url }}
runs:
using: "composite"
steps:
- name: "Setup Python"
id: python-setup
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: "pip"
cache-dependency-path: ${{ inputs.release-requirements }}
- name: "Install Release Dependencies"
id: python-install
env:
REQ_FILE: ${{ inputs.release-requirements }}
shell: bash
run: |
python -m pip install --upgrade pip
pip install setuptools setuptools_scm twine build
pip install -r $REQ_FILE
- name: "Prepare and Update CHANGELOG.md"
id: changelog-update
shell: bash
env:
VERSION: ${{ inputs.version }}
REPOSITORY: ${{ inputs.repository }}
GITHUB_TOKEN: ${{ inputs.github-token }}
BRANCH: ${{ inputs.ref }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
DATE=$(date +'%Y-%m-%d')
sed -i "/These changes are available on the \`.*\` branch, but have not yet been released\./{N;d;}" CHANGELOG.md
sed -i "s/## \[Unreleased\]/## [$VERSION] - $DATE/" CHANGELOG.md
sed -i "0,/## \[$VERSION\]/ s|## \[$VERSION\]|## [Unreleased]\n\nThese changes are available on the \`$BRANCH\` branch, but have not yet been released.\n\n### Added\n\n### Changed\n\n### Fixed\n\n### Removed\n\n&|" CHANGELOG.md
sed -i "s|\[unreleased\]:.*|[unreleased]: https://github.com/$REPOSITORY/compare/v$VERSION...HEAD\n[$VERSION]: https://github.com/$REPOSITORY/compare/$(git describe --tags --abbrev=0 @^)...v$VERSION|" CHANGELOG.md
git add CHANGELOG.md
git commit -m "chore(release): update CHANGELOG.md for version $VERSION"
- name: "Commit and Push Changelog to ${{ inputs.ref }}"
id: commit-main-branch
shell: bash
env:
VERSION: ${{ inputs.version }}
GITHUB_TOKEN: ${{ inputs.github-token }}
BRANCH: ${{ inputs.ref }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git push origin HEAD:$BRANCH
- name: "Push Changelog to Version Branch"
id: commit-version-branch
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
VERSION_BRANCH: ${{ inputs.version-branch-name }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git push origin HEAD:$VERSION_BRANCH
- name: "Create Git Tag"
id: create-git-tag
shell: bash
env:
VERSION: ${{ inputs.version }}
GITHUB_TOKEN: ${{ inputs.github-token }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag v$VERSION -m "Release version $VERSION"
- name: "Verify Version"
id: python-version-verify
shell: bash
run: python -m setuptools_scm
- name: "Build Package"
id: python-version-build
shell: bash
run: |
python3 -m build --sdist
python3 -m build --wheel
- name: "Create GitHub Release"
uses: softprops/action-gh-release@v2.0.8
id: gh-release
with:
tag_name: "v${{ inputs.version }}"
name: "v${{ inputs.version }}"
generate_release_notes: true
draft: false
prerelease: ${{ inputs.is-rc == 'true' }}
files: |
dist/*.whl
dist/*.tar.gz
token: ${{ inputs.github-token }}
make_latest: true
repository: ${{ inputs.repository }}
target_commitish: ${{ inputs.ref }}
- name: "Publish package distributions to PyPI"
uses: pypa/gh-action-pypi-publish@v1.9.0
env:
name: "pypi"
url: "https://pypi.org/p/${{ inputs.pypi-package }}"
with:
password: ${{ inputs.pypi-token }}
user: ${{ inputs.pypi-username }}