-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16441b3
commit a62c88b
Showing
1 changed file
with
51 additions
and
131 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,131 +1,51 @@ | ||
name: release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
versionNumber: | ||
description: 'Release version number (v#.#.#)' | ||
type: string | ||
required: true | ||
|
||
permissions: | ||
contents: read # Changelog commit operations use service account PAT | ||
|
||
env: | ||
CI_COMMIT_AUTHOR: hc-github-team-tf-provider-devex | ||
CI_COMMIT_EMAIL: [email protected] | ||
|
||
jobs: | ||
changelog-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.changelog-version.outputs.version }} | ||
steps: | ||
- id: changelog-version | ||
run: echo "version=$(echo "${{ inputs.versionNumber }}" | cut -c 2-)" >> "$GITHUB_OUTPUT" | ||
|
||
changelog: | ||
needs: [ changelog-version, meta-version ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | ||
with: | ||
fetch-depth: 0 | ||
# Default input is the SHA that initially triggered the workflow. As we created a new commit in the previous job, | ||
# to ensure we get the latest commit we use the ref for checkout: 'refs/heads/<branch_name>' | ||
ref: ${{ github.ref }} | ||
# Avoid persisting GITHUB_TOKEN credentials as they take priority over our service account PAT for `git push` operations | ||
# More details: https://github.com/actions/checkout/blob/b4626ce19ce1106186ddf9bb20e706842f11a7c3/adrs/0153-checkout-v2.md#persist-credentials | ||
persist-credentials: false | ||
- name: Batch changes | ||
uses: miniscruff/changie-action@6dcc2533cac0495148ed4046c438487e4dceaa23 # v2.0.0 | ||
with: | ||
version: latest | ||
args: batch ${{ needs.changelog-version.outputs.version }} | ||
- name: Merge changes | ||
uses: miniscruff/changie-action@6dcc2533cac0495148ed4046c438487e4dceaa23 # v2.0.0 | ||
with: | ||
version: latest | ||
args: merge | ||
- name: Git push changelog | ||
run: | | ||
git config --global user.name "${{ vars.TF_DEVEX_CI_COMMIT_AUTHOR }}" | ||
git config --global user.email "${{ vars.TF_DEVEX_CI_COMMIT_EMAIL }}" | ||
git add . | ||
git commit -a -m "Update changelog" | ||
git push "https://${{ vars.TF_DEVEX_CI_COMMIT_AUTHOR }}:${{ secrets.TF_DEVEX_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" | ||
meta-version: | ||
needs: changelog-version | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | ||
with: | ||
fetch-depth: 0 | ||
# Default input is the SHA that initially triggered the workflow. As we created a new commit in the previous job, | ||
# to ensure we get the latest commit we use the ref for checkout: 'refs/heads/<branch_name>' | ||
ref: ${{ github.ref }} | ||
# Avoid persisting GITHUB_TOKEN credentials as they take priority over our service account PAT for `git push` operations | ||
# More details: https://github.com/actions/checkout/blob/b4626ce19ce1106186ddf9bb20e706842f11a7c3/adrs/0153-checkout-v2.md#persist-credentials | ||
persist-credentials: false | ||
- name: Update meta package SDKVersion | ||
run: sed -i "s/var SDKVersion =.*/var SDKVersion = \"${{ needs.changelog-version.outputs.version }}\"/" meta/meta.go | ||
- name: Git push meta | ||
run: | | ||
git config --global user.name "${{ vars.TF_DEVEX_CI_COMMIT_AUTHOR }}" | ||
git config --global user.email "${{ vars.TF_DEVEX_CI_COMMIT_EMAIL }}" | ||
git add meta/meta.go | ||
git commit -m "Update meta package SDKVersion" | ||
git push "https://${{ vars.TF_DEVEX_CI_COMMIT_AUTHOR }}:${{ secrets.TF_DEVEX_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" | ||
release-tag: | ||
needs: changelog | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | ||
with: | ||
fetch-depth: 0 | ||
# Default input is the SHA that initially triggered the workflow. As we created a new commit in the previous job, | ||
# to ensure we get the latest commit we use the ref for checkout: 'refs/heads/<branch_name>' | ||
ref: ${{ github.ref }} | ||
# Avoid persisting GITHUB_TOKEN credentials as they take priority over our service account PAT for `git push` operations | ||
# More details: https://github.com/actions/checkout/blob/b4626ce19ce1106186ddf9bb20e706842f11a7c3/adrs/0153-checkout-v2.md#persist-credentials | ||
persist-credentials: false | ||
|
||
- name: Git push release tag | ||
run: | | ||
git config --global user.name "${{ vars.TF_DEVEX_CI_COMMIT_AUTHOR }}" | ||
git config --global user.email "${{ vars.TF_DEVEX_CI_COMMIT_EMAIL }}" | ||
git tag "${{ inputs.versionNumber }}" | ||
git push "https://${{ vars.TF_DEVEX_CI_COMMIT_AUTHOR }}:${{ secrets.TF_DEVEX_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" "${{ inputs.versionNumber }}" | ||
goreleaser: | ||
needs: [ changelog-version, changelog, release-tag ] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # Needed for goreleaser to create GitHub release | ||
issues: write # Needed for goreleaser to close associated milestone | ||
steps: | ||
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | ||
with: | ||
ref: ${{ inputs.versionNumber }} | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 | ||
with: | ||
go-version-file: 'go.mod' | ||
|
||
- name: Generate Release Notes | ||
run: | | ||
cd .changes | ||
sed -e "1{/# /d;}" -e "2{/^$/d;}" ${{ needs.changelog-version.outputs.version }}.md > /tmp/release-notes.txt | ||
- uses: goreleaser/goreleaser-action@5742e2a039330cbb23ebf35f046f814d4c6ff811 # v5.1.0 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
args: release --release-notes /tmp/release-notes.txt --clean | ||
# This GitHub action can publish assets for release when a tag is created. | ||
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0). | ||
# | ||
# This uses an action (crazy-max/ghaction-import-gpg) that assumes you set your | ||
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE` | ||
# secret. If you would rather own your own GPG handling, please fork this action | ||
# or use an alternative one for key handling. | ||
# | ||
# You will need to pass the `--batch` flag to `gpg` in your signing step | ||
# in `goreleaser` to indicate this is being used in a non-interactive mode. | ||
# | ||
name: release | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
permissions: | ||
contents: write | ||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
- | ||
name: Unshallow | ||
run: git fetch --prune --unshallow | ||
- | ||
name: Set up Go | ||
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 | ||
with: | ||
go-version-file: '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@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} | ||
# GitHub sets this automatically | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |