Repository navigation
193 lines (187 loc) · 7.29 KB
/
Copy pathrelease.yml
File metadata and controls
193 lines (187 loc) · 7.29 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Publish to PyPI
on:
workflow_dispatch:
inputs:
part:
description: "Semver part to bump (major, minor, patch)"
type: choice
required: true
default: "patch"
options: ["major", "minor", "patch"]
dry-run:
description: "Dry run"
type: boolean
required: true
default: true
python-version:
description: "Python version used to build the distribution"
type: choice
required: true
default: "3.11"
options: ["3.10", "3.11", "3.12", "3.13"]
jobs:
bump:
name: Bump version
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
outputs:
VERSION: ${{ steps.get-version-and-commit-sha.outputs.VERSION }}
SHORT_VERSION: ${{ steps.get-version-and-commit-sha.outputs.SHORT_VERSION }}
MAJOR_VERSION: ${{ steps.get-version-and-commit-sha.outputs.MAJOR_VERSION }}
MINOR_VERSION: ${{ steps.get-version-and-commit-sha.outputs.MINOR_VERSION }}
PATCH_VERSION: ${{ steps.get-version-and-commit-sha.outputs.PATCH_VERSION }}
VERSION_TAG: ${{ steps.get-version-and-commit-sha.outputs.VERSION_TAG }}
COMMIT_SHA: ${{ steps.get-version-and-commit-sha.outputs.COMMIT_SHA }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.AIBSGITHUB_PRIVATE_KEY }}
- name: Install uv
id: setup-uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ github.event.inputs.python-version }}
- name: Set up AllenInstitute Repo Authorization
uses: ./.github/actions/configure-org-repo-authorization
with:
token: ${{ secrets.AI_PACKAGES_TOKEN }}
- name: Get tags
run: git fetch --tags origin
- name: Configure git for github-actions[bot]
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Run Install
run: |
make install-release
shell: bash
- name: Bump version with bumpversion
run: |
source .venv/bin/activate
uvx --from bump-my-version bump-my-version bump ${{ github.event.inputs.part }}
- name: Commit and push with tags
if: ${{ github.event.inputs.dry-run == 'false' }}
run: |
git push --follow-tags
- name: Get version and commit SHA
id: get-version-and-commit-sha
run: |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
# remove the leading v from tag
version="${latest_tag:1}"
echo "VERSION=$version" >> $GITHUB_OUTPUT
major_version="$(cut -d '.' -f 1 <<< $version)"
echo "MAJOR_VERSION=$major_version" >> $GITHUB_OUTPUT
minor_version="$(cut -d '.' -f 2 <<< $version)"
echo "MINOR_VERSION=$minor_version" >> $GITHUB_OUTPUT
patch_version="$(cut -d '.' -f 3 <<< $version)"
echo "PATCH_VERSION=$patch_version" >> $GITHUB_OUTPUT
short_version="$major_version.$minor_version"
echo "SHORT_VERSION=$short_version" >> $GITHUB_OUTPUT
echo "VERSION_TAG=$latest_tag" >> $GITHUB_OUTPUT
commit_sha=$(git rev-list -n 1 $latest_tag)
echo "COMMIT_SHA=$commit_sha" >> $GITHUB_OUTPUT
- name: Show version
run: |
echo VERSION: ${{ steps.get-version-and-commit-sha.outputs.VERSION }}
echo SHORT_VERSION: ${{ steps.get-version-and-commit-sha.outputs.SHORT_VERSION }}
echo MAJOR_VERSION: ${{ steps.get-version-and-commit-sha.outputs.MAJOR_VERSION }}
echo MINOR_VERSION: ${{ steps.get-version-and-commit-sha.outputs.MINOR_VERSION }}
echo PATCH_VERSION: ${{ steps.get-version-and-commit-sha.outputs.PATCH_VERSION }}
echo VERSION_TAG: ${{ steps.get-version-and-commit-sha.outputs.VERSION_TAG }}
echo COMMIT_SHA: ${{ steps.get-version-and-commit-sha.outputs.COMMIT_SHA }}
build:
name: Build distribution
runs-on: ubuntu-latest
needs: bump
if: ${{ github.event.inputs.dry-run == 'false' }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.bump.outputs.VERSION_TAG }}
ssh-key: ${{ secrets.AIBSGITHUB_PRIVATE_KEY }}
- name: Install uv
id: setup-uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ github.event.inputs.python-version }}
- name: Set up AllenInstitute Repo Authorization
uses: ./.github/actions/configure-org-repo-authorization
with:
token: ${{ secrets.AI_PACKAGES_TOKEN }}
- name: Run Release
run: |
make dist
shell: bash
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: Publish to PyPI
needs: build
if: ${{ github.event.inputs.dry-run == 'false' }}
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/aibs-informatics-aws-lambda
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
create-github-release:
name: Create GitHub Release
needs: [bump, publish-to-pypi]
if: ${{ github.event.inputs.dry-run == 'false' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.bump.outputs.VERSION_TAG }}
name: ${{ needs.bump.outputs.VERSION_TAG }}
generate_release_notes: true
publish-docs:
name: Publish versioned docs
needs: [bump, publish-to-pypi]
if: ${{ github.event.inputs.dry-run == 'false' }}
runs-on: ubuntu-latest
permissions:
contents: write
# Shared with publish_docs.yml -- both commit to gh-pages, and mike rejects a
# deploy when its local view of the branch is behind the remote.
concurrency:
group: publish-docs
cancel-in-progress: false
steps:
- name: Checkout the release tag
uses: actions/checkout@v4
with:
ref: ${{ needs.bump.outputs.VERSION_TAG }}
fetch-depth: 0
- name: Fetch gh-pages branch
run: git fetch origin gh-pages:gh-pages || echo "No gh-pages branch yet; mike will create it."
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Sync dependencies
run: make install
- name: Configure git for github-actions[bot]
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Docs are versioned per minor release (SHORT_VERSION), so patch releases
# refresh the docs for their minor version instead of adding a new entry.
- name: Deploy ${{ needs.bump.outputs.SHORT_VERSION }} docs and move the latest alias
run: make docs-deploy-release DOCS_VERSION=${{ needs.bump.outputs.SHORT_VERSION }} DOCS_PUSH=true