From 14573b6da2a4baf06fa3164a6f2a653bf01ec59b Mon Sep 17 00:00:00 2001 From: Nicholas Wiersma Date: Tue, 17 Oct 2023 14:06:03 +0200 Subject: [PATCH] fix: allow CI to download modules (#2) --- .github/workflows/release.yaml | 54 +++++++++++++++++++++++++++++----- .github/workflows/test.yaml | 17 +++++++++-- .goreleaser.yml | 8 +---- Makefile | 2 +- go.mod | 4 +-- 5 files changed, 65 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 50bd3af..f2961f1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,10 +5,50 @@ on: name: release jobs: - terraform-provider-release: - name: 'Terraform Provider Release' - uses: hashicorp/ghaction-terraform-provider-release/.github/workflows/community.yml@v2 - secrets: - gpg-private-key: '${{ secrets.GPG_PRIVATE_KEY }}' - with: - setup-go-version-file: 'go.mod' + Release: + runs-on: ubuntu-latest + env: + GOPRIVATE: gitlab.com/nitrado/* + + steps: + - name: Install Go + if: success() + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Create .netrc + uses: extractions/netrc@v1 + with: + machine: gitlab.com + username: ${{ secrets.GITLAB_USERNAME }} + password: ${{ secrets.GITLAB_TOKEN }} + + - name: Cache Go modules + uses: actions/cache@v3 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Import GPG key + id: import_gpg + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSWORD }} + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + with: + version: latest + args: release --clean diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a9a02c0..259e4df 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -6,11 +6,12 @@ on: name: run tests jobs: - test: + Test: runs-on: ubuntu-latest env: GO_VERSION: "1.21" + GOPRIVATE: gitlab.com/nitrado/* GOLANGCI_LINT_VERSION: v1.54.2 steps: @@ -23,6 +24,13 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Create .netrc + uses: extractions/netrc@v1 + with: + machine: gitlab.com + username: ${{ secrets.GITLAB_USERNAME }} + password: ${{ secrets.GITLAB_TOKEN }} + - name: Cache Go modules uses: actions/cache@v3 with: @@ -31,10 +39,15 @@ jobs: restore-keys: | ${{ runner.os }}-go- + - name: Download Go modules + run: | + go mod download + - name: Run linter uses: golangci/golangci-lint-action@v3 with: version: ${{ env.GOLANGCI_LINT_VERSION }} + skip-pkg-cache: true args: --go ${{ env.GO_VERSION }} - name: Run tests @@ -44,4 +57,4 @@ jobs: uses: goreleaser/goreleaser-action@v5 with: version: latest - args: release --clean --snapshot + args: release --clean --snapshot --skip=sign diff --git a/.goreleaser.yml b/.goreleaser.yml index 4b17dc7..bc98c22 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -6,7 +6,7 @@ env: builds: - id: terraform-provider-ec - binary: "terraform-provider-ec_{{ .Version }}" + binary: "{{ .ProjectName }}_v{{ .Version }}" flags: - -trimpath ldflags: @@ -49,14 +49,8 @@ release: signs: - artifacts: checksum - stdin: '{{ .Env.GPG_PASSWORD }}' args: - "--batch" - - "--no-tty" - - "--pinentry-mode" - - "loopback" - - "--passphrase" - - '{{ .Env.GPG_PASSWORD }}' - "--local-user" - "{{ .Env.GPG_FINGERPRINT }}" - "--output" diff --git a/Makefile b/Makefile index 7358a5a..26a56d3 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ lint: #Build build: - @goreleaser release --clean --snapshot + @goreleaser release --clean --snapshot --skip=sign .PHONY: build # Schema Generation diff --git a/go.mod b/go.mod index ede30ab..3957f7e 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/nitrado/terraform-provider-ec -go 1.21.1 - -toolchain go1.21.3 +go 1.21 require ( github.com/ettle/strcase v0.1.1