-
Notifications
You must be signed in to change notification settings - Fork 3
96 lines (95 loc) · 3.43 KB
/
provider-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
on:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
name: release-provider
jobs:
check-provider-released:
runs-on: [ARM64, self-hosted, Linux]
steps:
- name: Check Release
id: provider_released
uses: actions/github-script@v5
with:
result-encoding: string
script: return context.ref.includes('refs/tags/terraform-provider-v')
outputs:
provider_released: ${{ steps.provider_released.outputs.result }}
go-release-provider:
runs-on: [ARM64, self-hosted, Linux]
if: ${{ needs.check-provider-released.outputs.provider_released == 'true' }}
needs:
- check-provider-released
steps:
# See https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
# For why we need to generate a token and not use the default
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.CZI_RELEASE_PLEASE_APP_ID }}
private_key: ${{ secrets.CZI_RELEASE_PLEASE_PK }}
- name: Parse Version
id: parse_version
uses: actions/github-script@v5
with:
result-encoding: string
script: return context.ref.replace('refs/tags/terraform-provider-', '')
- name: Create overall repo tag
uses: actions/github-script@v5
with:
script: |
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.parse_version.outputs.result }}',
sha: context.sha
})
} catch(e) {
// tag may have existed, ignore the error
console.log(e)
}
- uses: actions/checkout@v3
# we need to fetch all history and tags,
# so we build the proper version
# NOTE: this needs to happen after the tag is created so the tag is present locally
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: terraform/provider/go.mod
cache: true
-
name: Import GPG key
uses: crazy-max/ghaction-import-gpg@111c56156bcc6918c056dbef52164cfa583dc549 # v5.2.0
id: import_gpg
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@8f67e590f2d095516493f017008adc464e63adb1 # v4.1.0
with:
version: latest
workdir: terraform/provider
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
GORELEASER_CURRENT_TAG: ${{ steps.parse_version.outputs.result }}
-
name: Mirror release into terraform-provider-happy
id: triggerTerraformProviderWorkflow
uses: actions/github-script@v6
with:
github-token: ${{ steps.generate_token.outputs.token }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'chanzuckerberg',
repo: 'terraform-provider-happy',
workflow_id: 'mirror.yml',
ref: 'main',
});