Repository navigation
98 lines (85 loc) · 4.11 KB
/
Copy pathrelease.yml
File metadata and controls
98 lines (85 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
name: Release
# Bumps the version, tags main and publishes the GitHub Release: the two Lambda zips, the two templates
# (better-stack-full.yaml and better-stack-ai-sre.yaml) with the version stamped in, and SHA256SUMS. Deploying the release to the S3 buckets is the deploy recipe's job.
on:
workflow_dispatch:
inputs:
release:
description: 'Version bump'
required: true
type: choice
options: [patch, minor, major]
dry_run:
description: 'Build and show the version without tagging or releasing'
type: boolean
default: false
permissions:
contents: write
id-token: write
env:
AWS_REGION: us-east-1
AWS_ROLE_ARN: arn:aws:iam::251917137055:role/github-actions-e2e
jobs:
release:
runs-on: ubuntu-24.04-arm
steps:
- name: Releases are cut from main
if: ${{ github.ref != 'refs/heads/main' }}
run: |
echo "::error::run this on main, not ${{ github.ref_name }}"
exit 1
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Bump the version
run: |
LAST=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -1)
IFS=. read -r MAJOR MINOR PATCH <<<"${LAST#v}"
: "${MAJOR:=0}" "${MINOR:=0}" "${PATCH:=0}"
case "${{ inputs.release }}" in
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0;;
minor) MINOR=$((MINOR + 1)); PATCH=0;;
patch) PATCH=$((PATCH + 1));;
esac
echo "VERSION=$MAJOR.$MINOR.$PATCH" >> "$GITHUB_ENV"
echo "PREVIOUS_TAG=$LAST" >> "$GITHUB_ENV"
echo "${LAST:-no release yet} -> v$MAJOR.$MINOR.$PATCH"
- name: Build the Lambda zips
run: lambda/build.sh
- name: Stamp the templates and write the checksums
run: |
mkdir release
for template in cloudformation/full/better-stack-full.yaml cloudformation/ai-sre/better-stack-ai-sre.yaml; do
sed "s/^ Version: 0\.0\.0-dev$/ Version: $VERSION/" "$template" > "release/$(basename "$template")"
grep -q "^ Version: $VERSION$" "release/$(basename "$template")" || { echo "::error::$template has no 'Version: 0.0.0-dev' line to stamp"; exit 1; }
done
cp lambda/dist/firehose_logs_tag_enrichment.zip lambda/dist/firehose_metrics_tag_enrichment.zip release/
cd release
sha256sum firehose_logs_tag_enrichment.zip firehose_metrics_tag_enrichment.zip better-stack-full.yaml better-stack-ai-sre.yaml > SHA256SUMS
cat SHA256SUMS
- uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: ${{ env.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
- name: The stamped templates are valid CloudFormation
run: |
aws cloudformation validate-template --template-body file://release/better-stack-full.yaml >/dev/null
aws cloudformation validate-template --template-body file://release/better-stack-ai-sre.yaml >/dev/null
- uses: actions/upload-artifact@v7
with:
name: release-${{ env.VERSION }}
path: release/
retention-days: 30
- name: Tag and release
if: ${{ !inputs.dry_run }}
env:
GH_TOKEN: ${{ github.token }}
run: |
git tag "v$VERSION" "$GITHUB_SHA"
git push origin "v$VERSION"
# GitHub's generated notes: the merged pull requests since the previous tag and the full changelog link
gh api "repos/${{ github.repository }}/releases/generate-notes" -f tag_name="v$VERSION" ${PREVIOUS_TAG:+-f previous_tag_name="$PREVIOUS_TAG"} --jq .body > notes.md
{ echo; echo "## Artifacts"; echo; echo '```'; cat release/SHA256SUMS; echo '```'; } >> notes.md
gh release create "v$VERSION" --verify-tag --title "v$VERSION" --notes-file notes.md \
release/firehose_logs_tag_enrichment.zip release/firehose_metrics_tag_enrichment.zip release/better-stack-full.yaml release/better-stack-ai-sre.yaml release/SHA256SUMS
echo "released https://github.com/${{ github.repository }}/releases/tag/v$VERSION"