Skip to content

Commit

Permalink
fix: allow CI to download modules (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
nrwiersma committed Oct 17, 2023
1 parent 861a9de commit 14573b6
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 20 deletions.
54 changes: 47 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 15 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -44,4 +57,4 @@ jobs:
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean --snapshot
args: release --clean --snapshot --skip=sign
8 changes: 1 addition & 7 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:

builds:
- id: terraform-provider-ec
binary: "terraform-provider-ec_{{ .Version }}"
binary: "{{ .ProjectName }}_v{{ .Version }}"
flags:
- -trimpath
ldflags:
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ lint:
#Build

build:
@goreleaser release --clean --snapshot
@goreleaser release --clean --snapshot --skip=sign
.PHONY: build

# Schema Generation
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 14573b6

Please sign in to comment.