force-release #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~~ 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: custom-linux-medium | |
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: custom-linux-medium | |
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-googlebeta/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 |