From 9fd264c6a7c97f9f7d0bfd566106091c2ae6bb3d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira da Silva Date: Thu, 14 May 2020 20:59:41 -0300 Subject: [PATCH] Automate Louketo releases (#615) Fixes #615 --- .github/workflows/release.yml | 33 ++++++++++++++++++++ .goreleaser.yml | 57 +++++++++++++++++++++++++++++++++++ docs/release.md | 23 ++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml create mode 100644 docs/release.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..caf880f12 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Release + +# Only trigger this action when a new release is published +on: + release: + types: [published] + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + # Setup the workflow to use the specific version of Go + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: '^1.13.1' + # Checkout the repository + - name: Checkout + uses: actions/checkout@v2 + # Cleans up unreachable Git objects and convert a shallow clone to a regular one if needed + - name: Unshallow + run: git fetch --prune --unshallow + # Run tests prior to release + - name: Test + run: make test + # Publish the binaries + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 000000000..a05c82842 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,57 @@ +# Mark the release as not ready for production in case there is an +# indicator for this in the tag e.g. v1.0.0-rc1 +# See: https://goreleaser.com/customization/release/ +release: + prerelease: auto +# Prune any dependencies that are no longer needed before the build starts +before: + hooks: + - go mod tidy +builds: + # Make sure that cgo is disabled. See: https://golang.org/cmd/cgo/ +- env: + - CGO_ENABLED=0 + # Adds some metadata to the build like version, commit reference and the date of the build + ldflags: + - -w -X "main.build={{.Version}}" -X "main.gitsha={{ .FullCommit }}" -X "main.compiled={{ .Date }}" +- id: macos + goos: [darwin] + goarch: [amd64] + +- id: linux + goos: [linux] + goarch: [amd64] + +- id: windows + goos: [windows] + goarch: [amd64] +# Generate the checksum for each file +checksum: + name_template: '{{ .ProjectName }}-checksum.txt' + algorithm: sha512 +# Generate the changelog to be included into the release notes +changelog: + sort: asc + filters: + # Exclude commit messages matching the regex listed below + exclude: + - "^test:" + - Merge pull request + - Merge branch +# The artifacts to be uploaded +archives: + - id: nix + builds: [macos, linux] + # Generate the compresed files based on the following templates + name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + # All files will be in a single directory. For example: louketo_0.0.1_linux_amd64 + wrap_in_directory: true + # Replacement for the Platform name. Instead of have -darwin, replace by macOS + replacements: + darwin: macOS + format: tar.gz + - id: windows + builds: [windows] + # All files will be in a single directory. For example: louketo_0.0.1_linux_amd64 + wrap_in_directory: true + format: zip \ No newline at end of file diff --git a/docs/release.md b/docs/release.md new file mode 100644 index 000000000..4369c72b4 --- /dev/null +++ b/docs/release.md @@ -0,0 +1,23 @@ +# Release process + +## Before doing a release + +* Make sure that all the issues in the milestones are resolved +* Make sure CI is passing + +## Drafting a new release + +The release process was automated to release builds based on the Git tag when a new draft release is created. + +### Steps + +1. Visit https://github.com/louketo/louketo-proxy/releases/new +2. Choose a new tag version based on [Semantic Versioning 2.0.0](https://semver.org/) and pick the target branch. +3. Choose the release title and add a proper description +4. Publish the release + +The release process should be triggered by GitHub actions and once it's finished, all the binaries should be available in the release page. See the video below: + +[![Release demo](http://img.youtube.com/vi/OkDd91L6GuQ/0.jpg)](http://www.youtube.com/watch?v=OkDd91L6GuQ "Release demo") + +