From 14e7970a96bbbcdd8d100de5d82928b3e5c2c34d Mon Sep 17 00:00:00 2001 From: Zulh <75463191+zulh-civo@users.noreply.github.com> Date: Thu, 30 Sep 2021 16:45:39 +0800 Subject: [PATCH] Modify GH Actions (#98) --- .auto-changelog-config | 5 +++ .auto-changelog-template.hbs | 18 ++++++++++ .github/workflows/release.yml | 63 ++++++++++++++++++++++++++--------- 3 files changed, 71 insertions(+), 15 deletions(-) create mode 100644 .auto-changelog-config create mode 100644 .auto-changelog-template.hbs diff --git a/.auto-changelog-config b/.auto-changelog-config new file mode 100644 index 00000000..2c36384e --- /dev/null +++ b/.auto-changelog-config @@ -0,0 +1,5 @@ +{ + "template": ".auto-changelog-template.hbs", + "commitLimit": 100, + "ignoreCommitPattern": "Update docs and CHANGELOG.md" +} diff --git a/.auto-changelog-template.hbs b/.auto-changelog-template.hbs new file mode 100644 index 00000000..c237fd8e --- /dev/null +++ b/.auto-changelog-template.hbs @@ -0,0 +1,18 @@ +{{#each releases}} + + ## [{{title}}](https://github.com/civo/terraform-provider-civo/releases/tag/{{title}}) ({{niceDate}}) + + {{#if merges}} + ### Merged + {{#each merges}} + - [#{{id}}]({{href}}) - {{message}} + {{/each}} + {{/if}} + + {{#if commits}} + ### Commits + {{#each commits}} + - [{{shorthash}}]({{href}}) - {{subject}} + {{/each}} + {{/if}} +{{/each}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b5a3571d..55ffa16d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,34 +1,67 @@ -name: goreleaser +name: Release on: - push: - tags: - - 'v*.*.*' + workflow_dispatch: + inputs: + newVersionTag: + description: 'New version tag (e.g. v0.10.11)' + required: true jobs: - goreleaser: + release: runs-on: ubuntu-latest steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v2 - - - name: Unshallow + + - name: Unshallow run: git fetch --prune --unshallow - - - name: Set up Go + + - name: Set up Go uses: actions/setup-go@v2 with: go-version: 1.16.x - - - name: Import GPG key + + - name: Install and run tfplugindocs CLI + run: | + mkdir downloads + cd downloads + wget https://github.com/hashicorp/terraform-plugin-docs/releases/download/v0.5.0/tfplugindocs_0.5.0_linux_amd64.zip + unzip tfplugindocs_0.5.0_linux_amd64.zip + cd .. + mv downloads/tfplugindocs . + ./tfplugindocs generate + rm -rf ./tfplugindocs downloads + + - name: Install and run auto-changelog CLI + run: | + npm i -g auto-changelog@2.3.0 + auto-changelog --config=.auto-changelog-config --latest-version=${{ github.event.inputs.newVersionTag }} + + - name: Setup Git config + run: | + git config user.name "GitHub Actions" + git config user.email "<>" + + - name: Add and commit generated files + run: | + git add . + git commit -m "Update docs and CHANGELOG.md" + + - name: Create a tag and push + run: | + git pull origin master + git tag -a ${{ github.event.inputs.newVersionTag }} -m "" + git push origin master --follow-tags + + - name: Import GPG key id: import_gpg uses: paultyng/ghaction-import-gpg@v2.1.0 env: GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - - - name: Run GoReleaser + + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: args: release --rm-dist