-
Notifications
You must be signed in to change notification settings - Fork 7
84 lines (79 loc) · 2.86 KB
/
release-cli.yml
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
name: 'FOASCLI New Release'
run-name: 'Release ${{ inputs.version_number }} (skip tests: ${{ inputs.skip_tests }}, use existing tag: ${{ inputs.use_existing_tag}})'
# Used for creating a new release. This workflow will run qa acceptance tests, create a new tag, and generate the release with GoReleaser.
on:
workflow_dispatch:
inputs:
version_number:
description: 'Version number (e.g., v1.0.0, v1.0.0-pre, v1.0.0-pre1)'
required: true
skip_tests:
description: 'Set value to `true` to skip tests, default is `false`'
default: 'false'
use_existing_tag:
description: 'Set value to `true` to use an existing tag for the release process, default is `false`'
default: 'false'
jobs:
create-tag:
runs-on: ubuntu-latest
if: >-
!cancelled()
&& inputs.use_existing_tag == 'false'
steps:
- name: Validation of version format
run: |
echo "${{ inputs.version_number }}" | grep -P '^v\d+\.\d+\.\d+(-pre[A-Za-z0-9-]*)?$'
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Get the latest commit SHA
id: get-sha
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Create release tag
uses: rickstaa/action-create-tag@a1c7777fcb2fee4f19b0f283ba888afa11678b72
with:
tag: ${{ inputs.version_number }}
commit_sha: ${{ steps.get-sha.outputs.sha }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.PASSPHRASE }}
run-tests:
needs: [ create-tag ]
if: >-
!cancelled()
&& !contains(needs.*.result, 'failure')
&& inputs.skip_tests == 'false'
secrets: inherit
uses: ./.github/workflows/code-health-tools.yml
release:
runs-on: ubuntu-latest
needs: [ run-tests ]
# Release is skipped if there are failures in previous steps
if: >-
!cancelled()
&& !contains(needs.*.result, 'failure')
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
ref: ${{ inputs.version_number }}
- name: Set up Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed
with:
go-version-file: 'tools/cli/go.mod'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf
with:
version: '~> v2'
workdir: tools/cli
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
failure-handler:
name: Failure Handler
needs: [ release ]
if: ${{ always() && contains(needs.*.result, 'failure') }}
uses: ./.github/workflows/failure-handler.yml
with:
env: "prod"
release_name: "FOASCLI"
secrets:
jira_api_token: ${{ secrets.JIRA_API_TOKEN }}