From 932fd82fcbf1b7bc5c4d7258118aa4b64f5803d4 Mon Sep 17 00:00:00 2001 From: Nicholas Wiersma Date: Tue, 17 Oct 2023 11:14:57 +0200 Subject: [PATCH] fix: allow CI to download modules --- .github/workflows/release.yaml | 52 +++++++++++++++++++++++++++++----- .github/workflows/test.yaml | 17 +++++++++-- .goreleaser.yml | 8 +----- Makefile | 2 +- 4 files changed, 62 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 50bd3af..c605bd8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,10 +5,48 @@ 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 + + - 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