Repository navigation
146 lines (122 loc) · 4.11 KB
/
Copy pathcreate-release.yml
File metadata and controls
146 lines (122 loc) · 4.11 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
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
# Create a new release with the specified version
name: Create New Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (must be in format <MAJOR>.<MINOR>.<PATCH>, e.g. 1.1.1)'
required: true
type: string
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
jobs:
verify-input:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Verify input
env:
VERSION: ${{ inputs.version }}
run: |
# Make sure the input matches the intended format
SEMVER_REGEX="^([0-9]+)\.([0-9]+)\.([0-9]+)$"
if [[ ! "$VERSION" =~ $SEMVER_REGEX ]]; then
echo "::error::Invalid version format '$VERSION'. Must match X.Y.Z (e.g., 1.0.4)"
exit 1
fi
TAG="v$VERSION"
# Fail if the tag already exists
if git ls-remote --exit-code --tags origin "refs/tags/$TAG" >/dev/null 2>&1; then
echo "Error: Tag $TAG already exists. Aborting."
exit 1
fi
echo "Creating Tag $TAG ..."
run-test:
needs: verify-input
permissions:
contents: read
id-token: write
uses: ./.github/workflows/python-package.yml
create-release:
needs: run-test
runs-on: ubuntu-latest
permissions:
contents: write
environment: release
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Draft release v${{ inputs.version }}
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ inputs.version }}
run: |
gh release create "v$VERSION" \
--title "v$VERSION" \
--generate-notes \
--target "$GITHUB_SHA"
echo "Drafted release v$VERSION"
release-build:
needs: create-release
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-tags: true
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.x"
- name: build release distributions
run: |
set -euo pipefail
pip install build
python -m build
- name: upload artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: release-dists
path: dist/
pypi-publish-test:
needs: release-build
runs-on: ubuntu-latest
environment: publish-test
permissions:
id-token: write
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
with:
name: release-dists
path: dist/
- name: Publish release distributions to Test PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
READ-PLEASE:
needs: pypi-publish-test
runs-on: ubuntu-latest
steps:
- name: Review Instructuons (PLEASE READ)
run: |
echo "Please do the following before approving release for prod.
Go to https://test.pypi.org/project/aws-secretsmanager-caching/
Check the page for completeness. There should be a new version published, and two artifacts in the "Release files" section: a wheel (.whl) and a source distribution (.tar.gz)" >> $GITHUB_STEP_SUMMARY
pypi-publish:
needs: READ-PLEASE
runs-on: ubuntu-latest
environment: publish
permissions:
id-token: write
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
with:
name: release-dists
path: dist/
- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1