-
Notifications
You must be signed in to change notification settings - Fork 158
74 lines (63 loc) · 2.77 KB
/
remote-release-trigger.yml
File metadata and controls
74 lines (63 loc) · 2.77 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
name: Remote Release Trigger
on:
repository_dispatch:
types: [ cli-release ]
jobs:
remote-release-trigger:
runs-on: ubuntu-22.04
environment: CLI Automated Release
steps:
- name: Generate App Installation Token
id: generate_token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # pin@v1
with:
app_id: ${{ secrets.CLI_RELEASE_APP_ID }}
private_key: ${{ secrets.CLI_RELEASE_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v6
with:
# We want to checkout the main branch
ref: 'main'
fetch-depth: 0
- name: Get previous tag
id: previoustag
uses: WyriHaximus/github-action-get-previous-tag@04e8485ecb6487243907e330d522ff60f02283ce # pin@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate the desired release version
id: calculate_version
uses: actions/github-script@v8
env:
SPEC_VERSION: ${{ github.event.client_payload.spec_version }}
PREVIOUS_CLI_VERSION: ${{ steps.previoustag.outputs.tag }}
with:
result-encoding: string
version: ${{ steps.previoustag.outputs.tag }}
script: |
let spec_version_segments = process.env.SPEC_VERSION.replace("v", "").split(".");
let cli_version_segments = process.env.PREVIOUS_CLI_VERSION.replace("v", "").split(".");
// Default to a patch version bump
let bump_idx = 2;
// This is a minor version bump
if (spec_version_segments[2] == "0") {
bump_idx = 1;
// The patch number should revert to 0
cli_version_segments[2] = "0"
}
// Bump the version
cli_version_segments[bump_idx] = (parseInt(cli_version_segments[bump_idx]) + 1).toString()
return "v" + cli_version_segments.join(".")
- name: Calculate the SHA of HEAD on the main branch
id: calculate_head_sha
run: echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- uses: rickstaa/action-create-tag@a1c7777fcb2fee4f19b0f283ba888afa11678b72 # pin@v1
with:
tag: ${{ steps.calculate_version.outputs.result }}
commit_sha: ${{ steps.calculate_head_sha.outputs.commit_sha }}
- name: Release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # pin@v2.5.0
with:
target_commitish: 'main'
token: ${{ steps.generate_token.outputs.token }}
body: Built from Linode OpenAPI spec ${{ github.event.client_payload.spec_version }}
tag_name: ${{ steps.calculate_version.outputs.result }}