-
Notifications
You must be signed in to change notification settings - Fork 2
188 lines (180 loc) · 6.96 KB
/
Copy pathrelease.yml
File metadata and controls
188 lines (180 loc) · 6.96 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
name: Release
on:
push:
tags:
- "*/[0-9]*"
workflow_dispatch:
# Trigger the action with workflow_dispatch.
# Any steps or jobs that make side-effect should be skipped on the workflow_dispatch.
# Note generating steps only work if the hardcoded tag is the latest version of the package.
inputs:
tag:
description: 'Release tag - hardcoded for dry-run test.'
required: true
type: string
env:
PIXI_FROZEN: true
PIXI_NO_INSTALL: true
jobs:
determine-package:
name: Determine package and version, last-version.
runs-on: ubuntu-slim
outputs:
package: ${{ steps.parse.outputs.package }}
version: ${{ steps.parse.outputs.version }}
lastversion: ${{ steps.last-version-parse.outputs.lastversion }}
env:
DRYRUN: ${{ github.event_name == 'workflow_dispatch' }}
steps:
- id: parse
name: Parse package and version name.
run: |
if [ ${DRYRUN} = true ]; then
TAG=${{ inputs.tag }}
else
TAG="${GITHUB_REF#refs/tags/}"
fi
PACKAGE="${TAG%%/*}"
VERSION="${TAG#*/}"
echo "package=${PACKAGE}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v6
with:
fetch-tags: true
- id: last-version-parse
name: Parse the previous version if possible.
continue-on-error: true # Previous version may not exist.
run: |
PACKAGE=${{ steps.parse.outputs.package }}
VERSION=${{ steps.parse.outputs.package }}
previous_releases=($(git tag -l ${PACKAGE}/* --sort creatordate))
echo "Previous releases: ${previous_releases[@]}"
if [[ ${#previous_releases[@]} -gt 1 ]]; then
LAST_RELEASE=${previous_releases[-2]}
if [[ "${LAST_RELEASE}" =~ ^(^ess[^@]+)\/([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
echo "lastversion=${BASH_REMATCH[2]}" >> "$GITHUB_OUTPUT"
echo "Found last release version: ${BASH_REMATCH[2]}"
fi
else
echo "No previous release found for the package."
fi
build:
name: Build ${{ needs.determine-package.outputs.package }}
needs: determine-package
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Copy LICENSE into package
run: cp LICENSE packages/${{ needs.determine-package.outputs.package }}/LICENSE
- name: Build package
run: pip install build && python -m build packages/${{ needs.determine-package.outputs.package }}
- uses: actions/upload-artifact@v7
with:
name: dist
path: packages/${{ needs.determine-package.outputs.package }}/dist/
publish:
name: Publish to PyPI
needs: build
runs-on: ubuntu-24.04
environment: release
if: ${{ startsWith(github.ref, 'refs/tags/') && github.event_name != 'workflow_dispatch' }}
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
docs:
name: Build and publish docs
needs: [ determine-package, publish ]
permissions:
contents: write
uses: ./.github/workflows/docs.yml
with:
package: ${{ needs.determine-package.outputs.package }}
publish: true
linkcheck: false
assets:
name: Upload docs
needs: [ docs, determine-package ]
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/download-artifact@v8
with:
name: docs-${{ needs.determine-package.outputs.package }}
path: docs_html
- name: Zip documentation
run: |
PACKAGE=${{ needs.determine-package.outputs.package }}
VERSION=${{ needs.determine-package.outputs.version }}
mv docs_html documentation-${PACKAGE}-${VERSION}
zip -r documentation-${PACKAGE}-${VERSION}.zip documentation-${PACKAGE}-${VERSION}
- name: Upload release assets
env:
GH_TOKEN: ${{ github.token }}
ASSET-FILE-PATH: ./documentation-${{ needs.determine-package.outputs.package }}-${{ needs.determine-package.outputs.version }}.zip
TAG: ${{ needs.determine-package.outputs.package }}/${{ needs.determine-package.outputs.version }}
run: gh release upload ${TAG} ${ASSET-FILE-PATH} --clobber # Overwrite existing assets of the same name.
notes:
name: Update notes
needs: [ determine-package ]
runs-on: ubuntu-slim
if: ${{ always() && needs.determine-package.outputs.lastversion }}
permissions:
contents: write
env:
PACKAGE: ${{ needs.determine-package.outputs.package }}
VERSION: ${{ needs.determine-package.outputs.version }}
LASTVERSION: ${{ needs.determine-package.outputs.lastversion }}
steps:
- name: Download PR metadata cache
uses: actions/cache@v5.0.5
with:
key: ess-release-cache-${PACKAGE}-${VERSION}
restore-keys: ess-release-cache
path: .ess_release_cache
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Fetch depth must be 0 otherwise the git log comment won't find all relevant commits between tags.
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # 6.2.0
with:
python-version: "3.11"
- name: Install dependencise
run: pip install pydantic==2.13.3
- name: Download PR metadata
env:
GH_TOKEN: ${{ github.token }}
run: bash tools/download-release-diff-info.sh ${PACKAGE}/${VERSION} ${PACKAGE}/${LASTVERSION}
- name: Check downloaded cache
run: ls .ess_release_cache
- name: Generate release note
run: python tools/collect-release-notes.py --cur-tag ${PACKAGE}/${VERSION} --compare-tag ${PACKAGE}/${LASTVERSION}
- name: Download existing release note
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true # Release note might not exist yet.
run: | # If release does not exist yet, `existing-note.md` will be empty.
gh release view ${PACKAGE}/${VERSION} -R scipp/ess --json body -q .body > existing-note.md
if [ -s existing-note.md ]; then
cat existing-note.md >> new-release-note.md
fi
- name: Merge existing release note with generated note
run: cat .ess_release_cache/${PACKAGE}-${VERSION}-${PACKAGE}-${LASTVERSION}-releasenote.md >> new-release-note.md
- name: Check the generated note
run: cat new-release-note.md
- name: Upload release note and publish the release
if: ${{ github.event_name != 'workflow_dispatch' }}
env:
GH_TOKEN: ${{ github.token }}
run: gh release edit ${PACKAGE}/${VERSION} --notes-file "new-release-note.md"