forked from ChelseaKR/ceqa-preflight
-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (83 loc) · 3.04 KB
/
Copy pathrelease.yml
File metadata and controls
89 lines (83 loc) · 3.04 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
name: Release
on:
workflow_dispatch:
inputs:
tag:
description: "Existing signed stable SemVer tag (vX.Y.Z)"
required: true
type: string
permissions:
contents: read
concurrency:
group: release
cancel-in-progress: false
jobs:
authorize:
uses: ChelseaKR/portfolio-standards/.github/workflows/release-authorize.yml@3692aa5270d673f91f8571b4fc0ce1c622bf67e5
permissions:
contents: read
with:
tag: ${{ inputs.tag }}
build-and-attest:
needs: authorize
runs-on: ubuntu-latest
permissions:
contents: read
attestations: write
id-token: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.authorize.outputs.release-commit }}
persist-credentials: false
- uses: astral-sh/setup-uv@ae62891fec2bb8e7d6c99fc78c9fec3a63790f8d # v10.0.0
with:
python-version: "3.12"
enable-cache: false
# --locked, not --frozen: see the note in ci.yml. --frozen installs a
# lockfile that has drifted from pyproject.toml and exits 0, so it cannot
# gate drift, and a release must not be built from a resolution nobody
# reviewed.
- run: uv sync --all-groups --locked
- name: Require tag, package, and changelog versions to match
env:
TAG: ${{ needs.authorize.outputs.release-tag }}
run: |
set -euo pipefail
VERSION="${TAG#v}"
PACKAGE_VERSION="$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')"
test "${VERSION}" = "${PACKAGE_VERSION}"
grep -Fq "## [${VERSION}]" CHANGELOG.md
- run: make verify
- run: uv build
- run: uv run --with cyclonedx-bom cyclonedx-py environment --output-file dist/sbom.cdx.json
- uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: dist/*
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: release-assets
path: dist/*
if-no-files-found: error
publish-release:
needs: [authorize, build-and-attest]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: release-assets
path: dist
- name: Recheck immutable tag object and create the release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG: ${{ needs.authorize.outputs.release-tag }}
TAG_OBJECT_SHA: ${{ needs.authorize.outputs.tag-object-sha }}
run: |
set -euo pipefail
LIVE_TAG_OBJECT="$(gh api "repos/${GITHUB_REPOSITORY}/git/ref/tags/${TAG}" --jq .object.sha)"
test "${LIVE_TAG_OBJECT}" = "${TAG_OBJECT_SHA}"
gh release create "${TAG}" dist/* \
--title "ceqa-preflight ${TAG}" --generate-notes