From 02584d20ce1d6610cf9fd65acd7ada2ded825b53 Mon Sep 17 00:00:00 2001 From: Allison Doami Date: Mon, 21 Mar 2022 11:41:24 -0700 Subject: [PATCH] feat: Automatic release process (#621) --- .github/workflows/release.yml | 60 +++++++++++++++++++++++++++++++++++ .goreleaser.yml | 7 ---- Makefile | 19 ----------- codecov.yml | 9 ------ 4 files changed, 60 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100644 codecov.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..a94e63846 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +on: + push: + branches: + - main + +name: release-please +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v5 + id: configure-changelog + with: + result-encoding: string + script: | + const changelogTypes = [ + {type: "feat", section: "Features", hidden: false}, + {type: "chore", section: "Misc", hidden: false}, + {type: "fix", section: "BugFixes", hidden: false}, + ] + + return JSON.stringify(changelogTypes) + # See https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow + # For why we need to generate a token and not use the default + - name: Generate token + id: generate_token + uses: chanzuckerberg/github-app-token@v1.1.4 + with: + app_id: ${{ secrets.CZI_RELEASE_PLEASE_APP_ID }} + private_key: ${{ secrets.CZI_RELEASE_PLEASE_PK }} + + - name: release please + uses: google-github-actions/release-please-action@v3 + id: release + with: + release-type: simple + bump-minor-pre-major: true + changelog-types: ${{ steps.configure-changelog.outputs.result }} + token: ${{ steps.generate_token.outputs.token }} + + - uses: actions/checkout@v2 + # we need to fetch all history and tags + # so we build the proper version + with: + fetch-depth: 0 + if: ${{ steps.release.outputs.release_created }} + + - uses: actions/setup-go@v2 + with: + go-version: 1.17 + if: ${{ steps.release.outputs.release_created }} + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + if: ${{ steps.release.outputs.release_created }} diff --git a/.goreleaser.yml b/.goreleaser.yml index a0984c10d..f653fa3e7 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,7 +1,3 @@ -before: - hooks: - - make clean - builds: - binary: fogg env: @@ -23,9 +19,6 @@ archives: release: prerelease: false -env_files: - github_token: ~/.config/goreleaser/github_token - brews: - description: 'Terraform without pain.' tap: diff --git a/Makefile b/Makefile index 378e554f4..03e9df2a8 100644 --- a/Makefile +++ b/Makefile @@ -51,25 +51,6 @@ lint-all: lint-setup ## run the fast go linters TEMPLATES := $(shell find templates -not -name "*.go") -release: setup ## run a release - ./bin/bff bump - git push - goreleaser release -.PHONY: release - -release-prerelease: setup ## release to github as a 'pre-release' - go build ${LDFLAGS} . - version=`./fogg version`; \ - git tag v"$$version"; \ - git push; \ - git push origin v"$$version"; - goreleaser release -f .goreleaser.prerelease.yml --debug -.PHONY: release-prerelease - -release-snapshot: setup ## run a release - goreleaser release --snapshot -.PHONY: release-snapshot - build: fmt ## build the binary go build ${LDFLAGS} . .PHONY: build diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index c63a41424..000000000 --- a/codecov.yml +++ /dev/null @@ -1,9 +0,0 @@ -ignore: - - "vendor" -coverage: - status: - project: - default: - target: 70 - threshold: 2 - patch: off \ No newline at end of file