From 0aafba4de313c25ff70c1d4f7f2ad8f1aa110c3c Mon Sep 17 00:00:00 2001 From: franklin Date: Mon, 20 Feb 2023 11:04:34 +0100 Subject: [PATCH 1/7] chore: add release workflow --- .github/workflows/pull-requests.yml | 12 +++++------ .github/workflows/releases.yml | 31 +++++++++++++++++++++++++++++ .goreleaser.yml | 2 ++ 3 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/releases.yml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 8c56c22..98b3302 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -26,31 +26,31 @@ jobs: matrix=$(find . -type f -name "go.mod" -print0 | xargs -0 -n1 dirname | sort --unique | jq -R -s -c 'split("\n")[:-1]') echo "${matrix}" echo "::set-output name=matrix::${matrix}" - check: - name: Check + lint: needs: matrix runs-on: ubuntu-latest strategy: matrix: gomod: ${{ fromJson(needs.matrix.outputs.gomod) }} - env: - GOFLAGS: -mod=readonly - GOPROXY: https://proxy.golang.org steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: + cache: true + check-latest: true go-version-file: 'go.mod' - uses: golangci/golangci-lint-action@v3 with: + only-new-issues: true working-directory: ${{ matrix.gomod }} test: - name: Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: + cache: true + check-latest: true go-version-file: 'go.mod' - run: go test -v ./... diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml new file mode 100644 index 0000000..9f72302 --- /dev/null +++ b/.github/workflows/releases.yml @@ -0,0 +1,31 @@ +name: Releases + +on: + push: + tags: + - v*.*.* + workflow_dispatch: + +env: + GOFLAGS: -mod=readonly + GOPROXY: https://proxy.golang.org + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - run: git fetch --force --tags + - uses: actions/setup-go@v3 + with: + cache: true + check-latest: true + go-version-file: 'go.mod' + - uses: goreleaser/goreleaser-action@v4 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..2bb7412 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,2 @@ +builds: + - skip: true From ec8356e9a431c3605a4895e0ff785426251b7d9c Mon Sep 17 00:00:00 2001 From: franklin Date: Mon, 20 Feb 2023 11:05:45 +0100 Subject: [PATCH 2/7] chore: cancel prev run --- .github/workflows/pull-requests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 98b3302..23bad15 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -9,13 +9,16 @@ on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + env: GOFLAGS: -mod=readonly GOPROXY: https://proxy.golang.org jobs: matrix: - name: Matrix runs-on: ubuntu-latest outputs: gomod: ${{ steps.gomod.outputs.matrix }} From 466587f833604d06ef4bef8f8bb7d3842955c3b1 Mon Sep 17 00:00:00 2001 From: franklin Date: Mon, 20 Feb 2023 11:07:26 +0100 Subject: [PATCH 3/7] chore: remove only-new --- .github/workflows/pull-requests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 23bad15..5d89dd2 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -44,7 +44,6 @@ jobs: go-version-file: 'go.mod' - uses: golangci/golangci-lint-action@v3 with: - only-new-issues: true working-directory: ${{ matrix.gomod }} test: runs-on: ubuntu-latest From 46496400d461ca316ade96cf590e1ee5c00839e4 Mon Sep 17 00:00:00 2001 From: franklin Date: Mon, 20 Feb 2023 11:10:16 +0100 Subject: [PATCH 4/7] chore: use path matrix --- .github/workflows/pull-requests.yml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 5d89dd2..0672e80 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -18,23 +18,12 @@ env: GOPROXY: https://proxy.golang.org jobs: - matrix: - runs-on: ubuntu-latest - outputs: - gomod: ${{ steps.gomod.outputs.matrix }} - steps: - - uses: actions/checkout@v3 - - id: gomod - run: | - matrix=$(find . -type f -name "go.mod" -print0 | xargs -0 -n1 dirname | sort --unique | jq -R -s -c 'split("\n")[:-1]') - echo "${matrix}" - echo "::set-output name=matrix::${matrix}" lint: needs: matrix runs-on: ubuntu-latest strategy: matrix: - gomod: ${{ fromJson(needs.matrix.outputs.gomod) }} + path: [".", "example"] steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 @@ -44,7 +33,7 @@ jobs: go-version-file: 'go.mod' - uses: golangci/golangci-lint-action@v3 with: - working-directory: ${{ matrix.gomod }} + working-directory: ${{ matrix.path }} test: runs-on: ubuntu-latest steps: From 9040452a6d39b83f249bb06d47653775e664c58e Mon Sep 17 00:00:00 2001 From: franklin Date: Mon, 20 Feb 2023 11:11:07 +0100 Subject: [PATCH 5/7] chore: remove depends --- .github/workflows/pull-requests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 0672e80..8647089 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -19,7 +19,6 @@ env: jobs: lint: - needs: matrix runs-on: ubuntu-latest strategy: matrix: From b31b0e8bd52fd8fa10244cba86c367f36a0efbc6 Mon Sep 17 00:00:00 2001 From: franklin Date: Mon, 20 Feb 2023 11:16:36 +0100 Subject: [PATCH 6/7] chore: skip cache --- .github/workflows/pull-requests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 8647089..2796b4d 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - path: [".", "example"] + path: [".", "./example"] steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 @@ -32,6 +32,7 @@ jobs: go-version-file: 'go.mod' - uses: golangci/golangci-lint-action@v3 with: + skip-pkg-cache: true working-directory: ${{ matrix.path }} test: runs-on: ubuntu-latest From 2b94959e59c534e4ba549f6f32acf21e52072c06 Mon Sep 17 00:00:00 2001 From: franklin Date: Mon, 20 Feb 2023 11:17:55 +0100 Subject: [PATCH 7/7] chore: remove matrix --- .github/workflows/pull-requests.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 2796b4d..af48aa2 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -20,9 +20,6 @@ env: jobs: lint: runs-on: ubuntu-latest - strategy: - matrix: - path: [".", "./example"] steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 @@ -30,10 +27,10 @@ jobs: cache: true check-latest: true go-version-file: 'go.mod' + - uses: golangci/golangci-lint-action@v3 - uses: golangci/golangci-lint-action@v3 with: - skip-pkg-cache: true - working-directory: ${{ matrix.path }} + working-directory: example test: runs-on: ubuntu-latest steps: