From 8cabee48bd8500138a043e47012f76f69514ba4b Mon Sep 17 00:00:00 2001 From: ErwinsExpertise Date: Wed, 8 Dec 2021 13:17:52 -0500 Subject: [PATCH] Add autoreleaser workflow --- .github/workflows/notify-release.yml | 21 -------- .github/workflows/releaser.yml | 78 ++++++++++++++++++++++++++++ .goreleaser.yml | 25 +++++++++ 3 files changed, 103 insertions(+), 21 deletions(-) delete mode 100644 .github/workflows/notify-release.yml create mode 100644 .github/workflows/releaser.yml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/notify-release.yml b/.github/workflows/notify-release.yml deleted file mode 100644 index 6958d17..0000000 --- a/.github/workflows/notify-release.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: notify-release - -on: - push: - tags: v* - -jobs: - release: - runs-on: ubuntu-latest - name: Release Notification - steps: - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - - run: | - echo "{\"text\":\"GoVultr : Release https://github.com/vultr/govultr/releases/tag/${{ steps.get_version.outputs.VERSION }} \"}" > mattermost.json - - uses: mattermost/action-mattermost-notify@master - env: - MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} - MATTERMOST_USERNAME: ${{ secrets.MATTERMOST_USERNAME}} - MATTERMOST_ICON: ${{ secrets.MATTERMOST_ICON }} diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml new file mode 100644 index 0000000..668eeff --- /dev/null +++ b/.github/workflows/releaser.yml @@ -0,0 +1,78 @@ +name: "Automatic Releaser" + +on: + push: + branches: + - master + +permissions: + contents: write + +jobs: + check-commit: + runs-on: ubuntu-latest + outputs: + msg_check: ${{ steps.check-msg.outputs.match }} + steps: + - name: Check Message + id: check-msg + run: | + pattern="^Release v[0-9].[0-9].[0-9] #(minor|major|patch)$" + if [[ "${{ github.event.head_commit.message }}" =~ ${pattern} ]]; then + echo ::set-output name=match::true + fi + create-tag: + runs-on: ubuntu-latest + if: needs.check-commit.outputs.msg_check == 'true' + needs: check-commit + outputs: + new_tag: ${{ steps.tagger.outputs.new_tag }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: '0' + + - name: Bump version and push tag + id: tagger + uses: anothrNick/github-tag-action@1.36.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WITH_V: true + DEFAULT_BUMP: "none" + + goreleaser: + runs-on: ubuntu-latest + needs: create-tag + steps: + - + name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - + name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + release: + runs-on: ubuntu-latest + needs: ["goreleaser", "create-tag"] + name: Release Notification + steps: + - run: | + echo "{\"text\":\"GoVultr : Release https://github.com/${{ github.repository }}/releases/tag/${{ needs.create-tag.outputs.new_tag }} \"}" > mattermost.json + - uses: mattermost/action-mattermost-notify@master + env: + MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} + MATTERMOST_USERNAME: ${{ secrets.MATTERMOST_USERNAME}} + MATTERMOST_ICON: ${{ secrets.MATTERMOST_ICON }} \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..e683e43 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,25 @@ +before: + hooks: + - go mod download + - go generate ./... +builds: + - skip: true + +checksum: + name_template: "{{ .ProjectName }}_v{{ .Version }}_checksums.txt" + algorithm: sha256 + +snapshot: + name_template: "{{ .ProjectName }}_v{{ .Version }}" + +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + +release: + github: + owner: Vultr + name: govultr \ No newline at end of file