Skip to content

cli-release

cli-release #54

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@v3
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@v6
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@84c90e6ba79b47b5147dcb11ff25d6a0e06238ba # 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@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1
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 }}