-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (89 loc) · 3.29 KB
/
Copy pathcut-release.yml
File metadata and controls
98 lines (89 loc) · 3.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
# Cuts a CalVer release and walks it through QA to production.
#
# One run, one audit trail: `deploy-prod` deploys `needs.tag.outputs.tag`, the
# exact tag `deploy-qa` just built, so prod cannot ship something QA never saw.
# The pause before prod is the `production` Environment's required reviewers --
# an environment rule rather than a gate job, so it also covers the other route
# to prod (`promote-to-prod.yml`). A gate job would only guard this workflow.
name: Cut release
on:
workflow_dispatch: {}
jobs:
tag:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
concurrency: release
permissions:
contents: write
outputs:
tag: ${{ steps.version.outputs.tag }}
steps:
- name: Mint App installation token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: ${{ github.event.repository.name }}
permission-contents: write
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # need full tag history to compute the next serial
token: ${{ steps.app-token.outputs.token }}
persist-credentials: true
- name: Compute CalVer tag
id: version
run: |
YEAR_MONTH=$(date +'%y.%m')
SERIAL=$(git tag -l "v${YEAR_MONTH}.[0-9]*" | sed -E "s/^v${YEAR_MONTH}\.//" | sort -n | tail -1)
SERIAL=${SERIAL:-0}
NEXT=$((SERIAL + 1))
TAG="v${YEAR_MONTH}.${NEXT}"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Computed tag: $TAG"
- name: Validate CalVer tag format
env:
TAG: ${{ steps.version.outputs.tag }}
run: |
if [[ ! "$TAG" =~ ^v[0-9]{2}\.(0[1-9]|1[0-2])\.[1-9][0-9]*$ ]]; then
echo "::error::Tag '$TAG' does not match required CalVer format vYY.MM.SERIAL (e.g. v26.07.1)"
exit 1
fi
echo "Tag '$TAG' is valid."
- name: Tag and push
env:
TAG: ${{ steps.version.outputs.tag }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "$TAG"
git push origin "$TAG"
- name: Create GitHub release
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
with:
tag_name: ${{ steps.version.outputs.tag }}
generate_release_notes: true
deploy-qa:
needs: tag
permissions:
contents: read
uses: ./.github/workflows/deploy.yml
secrets: inherit
with:
ref: ${{ needs.tag.outputs.tag }}
environment: qa
# src/lib/config.ts's enum has no 'qa' member; 'staging' is the QA slot.
vite_environment: staging
app_version: ${{ needs.tag.outputs.tag }}
deploy-prod:
needs: [tag, deploy-qa]
permissions:
contents: read
uses: ./.github/workflows/deploy.yml
secrets: inherit
with:
ref: ${{ needs.tag.outputs.tag }}
environment: production
vite_environment: production
app_version: ${{ needs.tag.outputs.tag }}