forked from gravitational/teleport
-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (98 loc) · 4.06 KB
/
post-release.yaml
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
name: Post-release
on:
release:
types: [released] # released does not include prereleases
workflow_dispatch:
permissions:
contents: write
pull-requests: write
id-token: write
jobs:
release:
name: Collect release information
outputs:
type: ${{ steps.artifacts.outputs.type }}
version: ${{ steps.artifacts.outputs.version }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
# Release event metadata doesn't include "is latest" flag so we have
# to determine it another way.
- name: Determine release latest flag and version
id: artifacts
run: |
LATEST_RELEASE_ID=$(gh release view --json id -q .id)
CURRENT_RELEASE_ID=${{ github.event.release.node_id }}
if [ "$LATEST_RELEASE_ID" == "$CURRENT_RELEASE_ID" ]; then
echo "type=latest" >> "$GITHUB_OUTPUT"
else
echo "type=other" >> "$GITHUB_OUTPUT"
fi
echo "version=$(make -s print-version)" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ github.token }}
update-ami-ids:
name: Update AMI IDs
needs: release
if: needs.release.outputs.type == 'latest'
uses: gravitational/teleport/.github/workflows/update-ami-ids.yaml@master
secrets: inherit
with:
version: ${{ needs.release.outputs.version }}
update-docs-version:
name: Update docs version
runs-on: ubuntu-latest
environment: post-release
steps:
- name: Get Release Branch
id: get-branch
run: |
TAG=${{ github.event.release.tag_name }}
BRANCH="branch/$(echo -n $TAG | cut -d '.' -f 1)"
MAJOR=${BRANCH#"branch/v"} # trim the 'branch/v' prefix
VERSION=${TAG#"v"} # trim the leading v to get just the version
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
echo "major=$MAJOR" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Generate GitHub token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- name: Checkout Release Branch
uses: actions/checkout@v4
with:
ref: ${{ steps.get-branch.outputs.branch }}
- name: Make PR
run: |
BRANCH_NAME="release-auto-branch-$(date +%s)"
git config --global user.email "noreply@github.com"
git config --global user.name "GitHub"
# update versions in docs/config.json
# for docker images replace version number after <docker image name>:
jq --arg major ${{ steps.get-branch.outputs.major }} \
--arg version ${{ steps.get-branch.outputs.version }} \
'.variables.teleport.major_version |= $major |
.variables.teleport.version |= $version |
.variables.teleport.plugin.version |= $version |
.variables.teleport.latest_oss_docker_image |= sub(":.*";":")+$version |
.variables.teleport.latest_oss_debug_docker_image |= sub(":.*";":")+$version |
.variables.teleport.latest_ent_docker_image |= sub(":.*";":")+$version |
.variables.teleport.latest_ent_debug_docker_image |= sub(":.*";":")+$version' \
docs/config.json > docs/confignew.json
cat docs/confignew.json
mv docs/confignew.json docs/config.json
git add docs/config.json
git switch -c $BRANCH_NAME
git commit -am "[auto] docs: Update version to ${{ github.event.release.tag_name }}"
git push --set-upstream origin $BRANCH_NAME
gh pr create --fill --base=${{ steps.get-branch.outputs.branch }} \
--label=automated --label=documentation --label=no-changelog \
--reviewer=${{ github.event.release.author.login }}
echo "Docs PR: $(gh pr view --json url --jq .url)" >> "$GITHUB_STEP_SUMMARY"
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}