From c3fecbcb929d362bbfea5a9b42ff82f9441007cd Mon Sep 17 00:00:00 2001 From: Boris Bera Date: Thu, 13 Jul 2023 10:42:44 -0400 Subject: [PATCH] Fix goreleaser & revamp CI & repo in general (#402) * Update goreleaser config based on deprecations * Add goreleaser tests to the CI * Use --clean instead of --rm-dist * Fix artifacts upload and update setup-go action * Stop using our fork of aws-actions/configure-aws-credentials * Autopublish releases * Document release procedure in `CONTRIBUTING.md` * Add Dev Tooling as code owners --- .github/workflows/pr.yml | 57 ++++++++++++++++++++++++------ .github/workflows/tag.yml | 17 ++++----- .github/workflows/test-install.yml | 1 + .goreleaser.yml | 14 ++++---- CODEOWNERS | 1 + CONTRIBUTING.md | 15 ++++++++ README.md | 9 +---- 7 files changed, 79 insertions(+), 35 deletions(-) create mode 100644 CODEOWNERS create mode 100644 CONTRIBUTING.md diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7abda40e..e4e8bda2 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -3,10 +3,10 @@ on: pull_request: branches: - master -jobs: - build: - name: Test + - main +jobs: + test: permissions: id-token: write # required for AWS assume role @@ -16,16 +16,12 @@ jobs: runs-on: ${{ matrix.os }} steps: - - name: Setup Go - uses: actions/setup-go@v3 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 with: go-version: 1.17 - id: go - - - name: Checkout - uses: actions/checkout@v3 - - uses: coveooss/configure-aws-credentials-action@v1.7.0 + - uses: aws-actions/configure-aws-credentials@v2 with: aws-region: us-east-1 role-to-assume: arn:aws:iam::043612128888:role/nrd-oss-tgf-github-actions-ci @@ -34,3 +30,44 @@ jobs: env: AWS_REGION: us-east-1 run: go test -v ./... + + goreleaser-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: 1.17 + + - uses: goreleaser/goreleaser-action@b508e2e3ef3b19d4e4146d4f8fb3ba9db644a757 + with: + distribution: goreleaser + version: latest + args: check + + goreleaser-test-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # goreleaser needs the whole history to build the release notes + - uses: actions/setup-go@v4 + with: + go-version: 1.17 + + - uses: goreleaser/goreleaser-action@b508e2e3ef3b19d4e4146d4f8fb3ba9db644a757 + with: + distribution: goreleaser + version: latest + args: release --snapshot --clean + env: + CGO_ENABLED: 0 + + - uses: actions/upload-artifact@v3 + with: + name: test-release + path: | + dist/*.zip + dist/*.txt + if-no-files-found: error + retention-days: 5 diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 6272aec8..df641fc4 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -1,30 +1,25 @@ -name: Build +name: Release on Tag on: push: tags: - "v*" jobs: - build: + release: name: Tag runs-on: ubuntu-latest steps: - - name: Setup Go - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: go-version: 1.17 - id: go - - - name: Checkout - uses: actions/checkout@v3 + - uses: actions/checkout@v3 with: fetch-depth: 0 # goreleaser needs the whole history to build the release notes - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@b508e2e3ef3b19d4e4146d4f8fb3ba9db644a757 + - uses: goreleaser/goreleaser-action@b508e2e3ef3b19d4e4146d4f8fb3ba9db644a757 with: distribution: goreleaser version: latest - args: release --rm-dist + args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CGO_ENABLED: 0 diff --git a/.github/workflows/test-install.yml b/.github/workflows/test-install.yml index cf9fedca..3d72c65d 100644 --- a/.github/workflows/test-install.yml +++ b/.github/workflows/test-install.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - master + - main jobs: posix: diff --git a/.goreleaser.yml b/.goreleaser.yml index 839ffa43..498d1be0 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -16,15 +16,17 @@ builds: # Archive customization archives: - format: zip - - replacements: - amd64: 64-bits - darwin: macOS + name_template: >- + {{ .ProjectName }}_ + {{- .Version }}_ + {{- if eq .Os "darwin" }}macOS_ + {{- else }}{{ .Os }}_{{ end }} + {{- if eq .Arch "amd64" }}64-bits + {{- else }}{{ .Arch }}{{ end }} files: - nothing.* # GitHub release customization release: - draft: true - prerelease: true + prerelease: auto diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 00000000..d7ca5eea --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @coveooss/dev-tooling diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..eda8d5fa --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,15 @@ +# Contributing + +## Release procedure + +1. Find the latest tag +1. Look at changes between now and the current tag +1. Create a tag with the format `vX.Y.Z` + + You might be tempted to create a release through GitHub to create the tag. + Don't do that. We have a GitHub workflow in place that will create a release + from tags that get pushed. Create your tag with `git tag`. + +1. Push that tag +1. Wait for the [Release on Tag](https://github.com/coveooss/tgf/actions/workflows/tag.yml) to build your release. +1. Find your release and make sure things are as you expect them to be diff --git a/README.md b/README.md index 3a4e6f92..0bba1f93 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ outdated version. ## Installation -On `mac` and `linux`: +On `mac` and `linux`: You can run the `get-latest-tgf.sh` script to check if you have the latest version of tgf installed and install it as needed: @@ -362,10 +362,3 @@ Start a shell `fish` in the current folder Invokes `my_command` in your own docker image. As you can see, you can do whatever you need to with `tgf`. It is not restricted to only the pre-packaged Docker images, you can use it to run any program in any Docker images. Your imagination is your limit. - -## Development - -Builds are automatically launched on tagging. - -Tags with the format image-0.0.0 automatically launch a Docker images build that are available through Docker Hub. -Tags with the format v0.0.0 automatically launch a new release on Github for the TGF executable.