-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (113 loc) · 4.48 KB
/
force-release.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
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
113
114
# ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".
name: force-release
on:
workflow_dispatch:
inputs:
sha:
type: string
required: true
description: The sha of the commit to release
publish_to_go:
type: boolean
required: true
description: Whether to publish to Go Repository
jobs:
force-release:
runs-on: ubuntu-latest
permissions:
contents: write
env:
CI: "true"
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
ref: ${{ inputs.sha }}
fetch-depth: 0
- name: Set git config safe.directory
run: git config --global --add safe.directory $(pwd)
- name: Set git identity
run: |-
git config user.name "github-actions"
git config user.email "[email protected]"
- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: 18.12.0
- name: Install dependencies
run: yarn install --check-files --frozen-lockfile
- name: build
run: npx projen build
- name: Backup artifact permissions
run: cd dist && getfacl -R . > permissions-backup.acl
continue-on-error: true
- name: Upload artifact
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029
with:
name: build-artifact
path: dist
overwrite: true
force_release_golang:
name: Publish to Github Go Repository
needs: force-release
runs-on: ubuntu-latest
permissions:
contents: read
env:
CI: "true"
steps:
- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: 18.12.0
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: ^1.18.0
- name: Download build artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: build-artifact
path: dist
- name: Restore build artifact permissions
run: cd dist && setfacl --restore=permissions-backup.acl
continue-on-error: true
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
path: .repo
- name: Install Dependencies
run: cd .repo && yarn install --check-files --frozen-lockfile
- name: Extract build artifact
run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo
- name: Move build artifact out of the way
run: mv dist dist.old
- name: Create go artifact
run: cd .repo && npx projen package:go
- name: Setup Copywrite tool
uses: hashicorp/setup-copywrite@32638da2d4e81d56a0764aa1547882fc4d209636
- name: Copy copywrite hcl file
run: cp .repo/.copywrite.hcl .repo/dist/go/.copywrite.hcl
- name: Add headers using Copywrite tool
run: cd .repo/dist/go && copywrite headers
- name: Remove copywrite hcl file
run: rm -f .repo/dist/go/.copywrite.hcl
- name: Remove some text from the README that doesn't apply to Go
run: |-
sed -i 's/# CDKTF prebuilt bindings for/# CDKTF Go bindings for/' .repo/dist/go/*/README.md
sed -i -e '/## Available Packages/,/### Go/!b' -e '/### Go/!d;p; s/### Go/## Go Package/' -e 'd' .repo/dist/go/*/README.md
sed -i 's/### Go/## Go Package/' .repo/dist/go/*/README.md
sed -i -e '/API.typescript.md/,/You can also visit a hosted version/!b' -e 'd' .repo/dist/go/*/README.md
sed -i 's|Find auto-generated docs for this provider here:|Find auto-generated docs for this provider [here](https://github.com/cdktf/cdktf-provider-hcp/blob/main/docs/API.go.md).|' .repo/dist/go/*/README.md
sed -i -e '/### Provider Version/,/The provider version can be adjusted/!b' -e 'd' .repo/dist/go/*/README.md
- name: Copy the README file to the parent directory
run: cp .repo/dist/go/*/README.md .repo/dist/go/README.md
- name: Collect go Artifact
run: mv .repo/dist dist
- name: Release
if: ${{ inputs.publish_to_go }}
env:
GIT_USER_NAME: CDK for Terraform Team
GIT_USER_EMAIL: [email protected]
GITHUB_TOKEN: ${{ secrets.GO_GITHUB_TOKEN }}
run: npx -p publib@latest publib-golang