Skip to content

Commit d77dde1

Browse files
committed
add release workflows
1 parent 1853a92 commit d77dde1

File tree

2 files changed

+171
-0
lines changed

2 files changed

+171
-0
lines changed
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
---
2+
name: release-branch
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release/**
8+
paths-ignore:
9+
- '.github/**'
10+
- 'docs/**'
11+
- 'examples/**'
12+
- 'test/**'
13+
- 'README.*'
14+
15+
permissions:
16+
contents: write
17+
id-token: write
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: false
22+
23+
jobs:
24+
ci-codeowners:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- uses: mszostok/[email protected]
31+
# Pull request from a fork
32+
name: "Validate CODEOWNERS"
33+
with:
34+
checks: "syntax,duppatterns"
35+
owner_checker_allow_unowned_patterns: "false"
36+
37+
- uses: mszostok/[email protected]
38+
# Main branch / Pull request from the same repo
39+
name: "Validate CODEOWNERS"
40+
with:
41+
# For now, remove "files" check to allow CODEOWNERS to specify non-existent
42+
# files so we can use the same CODEOWNERS file for Terraform and non-Terraform repos
43+
# checks: "files,syntax,owners,duppatterns"
44+
checks: "syntax,duppatterns"
45+
owner_checker_allow_unowned_patterns: "false"
46+
47+
ci-readme:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v4
52+
53+
- name: Generate readme
54+
shell: bash
55+
run: |
56+
if [ ! -f README.yaml ]; then
57+
echo "Project does not have a README.yaml. Skipping..."
58+
exit 0
59+
fi
60+
61+
# A Makefile is required for build-harness and rebuilding the README.md from the README.yaml and rebuilding the README.md from the README.yaml and rebuilding the README.md from the README.yaml and rebuilding the README.md from the README.yaml
62+
if [ ! -f Makefile ]; then
63+
echo "Project does not have a Makefile";
64+
exit 1
65+
fi
66+
67+
make init
68+
make readme/build
69+
70+
- name: Check readme
71+
id: readme_diff
72+
shell: bash
73+
run: git diff --exit-code
74+
continue-on-error: true
75+
76+
- name: Auto-update README.md for bot pull requests
77+
id: auto_commit
78+
if: |
79+
steps.readme_diff.outcome == 'failure' &&
80+
startsWith(github.ref, 'renovate/')
81+
run: |
82+
git config user.name 'github-actions[bot]'
83+
git config user.email 'github-actions[bot]@users.noreply.github.com'
84+
git commit -a -m "Auto-update README.md"
85+
git push
86+
87+
- name: Status check
88+
shell: bash
89+
run: |
90+
git diff --exit-code && success="true" || success="false"
91+
if [ "$success" = "false" ]; then
92+
echo "README.md is outdated. Please run the following commands locally and push the file:"
93+
echo " make init"
94+
echo " make readme"
95+
exit 1
96+
fi
97+
98+
release-controller:
99+
runs-on: ubuntu-latest
100+
needs: [ci-readme, ci-codeowners]
101+
permissions:
102+
# write permission is required to create a github release
103+
contents: write
104+
# write permission is required for autolabeler
105+
# otherwise, read permission is required at least
106+
pull-requests: write
107+
steps:
108+
- name: Checkout
109+
uses: actions/checkout@v4
110+
with:
111+
fetch-depth: 0
112+
113+
- name: Fetch pull request for the given ref
114+
id: get-pull-request
115+
uses: 8BitJonny/[email protected]
116+
with:
117+
sha: ${{ github.sha }}
118+
119+
- name: Check duplicate
120+
id: check-duplicate
121+
run: |
122+
latest_hash=$(git rev-parse ${{ github.ref_name }})
123+
tags=$(git tag --contains "$latest_hash")
124+
if [[ -n $tags ]]; then
125+
echo "duplicate=true" >> "$GITHUB_OUTPUT"
126+
else
127+
echo "duplicate=false" >> "$GITHUB_OUTPUT"
128+
fi
129+
130+
- name: Do release
131+
if: steps.check-duplicate.outputs.duplicate == 'false'
132+
id: release
133+
uses: cloudposse/github-action-auto-release@v1
134+
with:
135+
prerelease: ${{ contains(steps.get-pull-request.outputs.pr_labels, 'prerelease') }}
136+
token: ${{ secrets.GITHUB_TOKEN }}
137+
138+
- name: Verify release # Workaround for https://github.com/release-drafter/release-drafter/issues/1313
139+
if: steps.check-duplicate.outputs.duplicate == 'false'
140+
shell: bash
141+
run: |
142+
echo 'Checking release id not empty: "${{ steps.release.outputs.id }}"'
143+
! test -z "${{ steps.release.outputs.id }}"
144+
145+
major-release-tagger:
146+
runs-on: ubuntu-latest
147+
needs: [release-controller]
148+
steps:
149+
- uses: cloudposse/github-action-major-release-tagger@v1
150+
with:
151+
token: ${{ secrets.GITHUB_TOKEN }}
152+
153+
release-branch-manager:
154+
runs-on: ubuntu-latest
155+
needs: [release-controller]
156+
steps:
157+
- uses: cloudposse/github-action-release-branch-manager@v1
158+
with:
159+
token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: cloudposse/github-action-major-release-tagger@v1

0 commit comments

Comments
 (0)