Skip to content

Commit

Permalink
Merge pull request #7 from octoenergy/fix-provider-version-publish
Browse files Browse the repository at this point in the history
Fix provider version publish
  • Loading branch information
maddocash authored Sep 25, 2024
2 parents 8c752b2 + 64261c0 commit 2ae7437
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 11 deletions.
78 changes: 78 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This config was automatically generated from your source code
# Stacks detected: artifact:go-executable:,cicd:github-actions:.github/workflows,deps:go:.
version: 2.1
jobs:
test-go:
# Install go modules and run tests
docker:
- image: cimg/go:1.23
steps:
- checkout
- restore_cache:
key: go-mod-{{ checksum "go.sum" }}
- run:
name: Download Go modules
command: go mod download
- run:
name: Print go mod help instructions
command: "echo \"go mod download will fail if you have private repositories \nOne way to fix this for private go modules that are hosted in github:\n 1. Add a GITHUB_TOKEN and GITHUB_USER to an org context. Please refer to https://circleci.com/docs/contexts/ for more informaiton on how to use contexts.\n 2. Add a .circleci/config.yml to your repository or use this config.yml as a starting template\n 3. Configure the jobs to use the newly created context which includes GITHUB_TOKEN and GITHUB_USER \n 4. Before downloading the modules you will need to add a step to execute \\\"go env -w GOPRIVATE=github.com/<OrgNameHere>\\\". \n\tThis allows go mod to install private repos under OrgNameHere.\n 5. You will also need to run \\\"git config --global url.\\\"https://$GITHUB_USER:[email protected]/<OrgNameHere>/\\\".insteadOf \\\"https://github.com/<OrgNameHere>/\\\"\\\"\n 6. Finally include the \\\"go mod download\\\" it should be able to fetch your private libraries now. \nFor gitlab private go modules, follow the same instructions as above but include your GITLAB_TOKEN and GITLAB_USER.\nThen use gitlab.com instead of github.com in steps 4 and 5.\nSee https://go.dev/ref/mod#private-modules for more details.\""
when: on_fail
- save_cache:
key: go-mod-{{ checksum "go.sum" }}
paths:
- /home/circleci/go/pkg/mod
- run:
name: Run tests
command: gotestsum --junitfile junit.xml
- store_test_results:
path: junit.xml
build-go-executables:
# Build go executables and store them as artifacts
docker:
- image: cimg/go:1.23
steps:
- checkout
- restore_cache:
key: go-mod-{{ checksum "go.sum" }}
- run:
name: Download Go modules
command: go mod download
- run:
name: Print go mod help instructions
command: "echo \"go mod download will fail if you have private repositories \nOne way to fix this for private go modules that are hosted in github:\n 1. Add a GITHUB_TOKEN and GITHUB_USER to an org context. Please refer to https://circleci.com/docs/contexts/ for more informaiton on how to use contexts.\n 2. Add a .circleci/config.yml to your repository or use this config.yml as a starting template\n 3. Configure the jobs to use the newly created context which includes GITHUB_TOKEN and GITHUB_USER \n 4. Before downloading the modules you will need to add a step to execute \\\"go env -w GOPRIVATE=github.com/<OrgNameHere>\\\". \n\tThis allows go mod to install private repos under OrgNameHere.\n 5. You will also need to run \\\"git config --global url.\\\"https://$GITHUB_USER:[email protected]/<OrgNameHere>/\\\".insteadOf \\\"https://github.com/<OrgNameHere>/\\\"\\\"\n 6. Finally include the \\\"go mod download\\\" it should be able to fetch your private libraries now. \nFor gitlab private go modules, follow the same instructions as above but include your GITLAB_TOKEN and GITLAB_USER.\nThen use gitlab.com instead of github.com in steps 4 and 5.\nSee https://go.dev/ref/mod#private-modules for more details.\""
when: on_fail
- save_cache:
key: go-mod-{{ checksum "go.sum" }}
paths:
- /home/circleci/go/pkg/mod
- run:
name: Create the ~/artifacts directory if it doesn't exist
command: mkdir -p ~/artifacts
- run:
name: Build executables
command: go build -o ~/artifacts ./...
- store_artifacts:
path: ~/artifacts
destination: executables
deploy:
# This is an example deploy job, not actually used by the workflow
docker:
- image: cimg/base:stable
steps:
# Replace this with steps to deploy to users
- run:
name: deploy
command: '#e.g. ./deploy.sh'
- run:
name: found github actions config
command: ':'
workflows:
build-and-test:
jobs:
- test-go
- build-go-executables:
requires:
- test-go
# - deploy:
# requires:
# - build-go-executables
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.23
cache: true
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.23.1

Expand All @@ -33,7 +33,7 @@ jobs:
with:
distribution: goreleaser
version: "~> v2"
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
Expand All @@ -45,8 +45,7 @@ jobs:
SPACELIFT_API_KEY_ENDPOINT: https://spacelift.ktl.net
SPACELIFT_API_KEY_ID: ${{ secrets.SPACELIFT_API_KEY_ID }}
SPACELIFT_API_KEY_SECRET: ${{ secrets.SPACELIFT_API_KEY_SECRET }}
run:
spacectl provider create-version --type=sendgrid
run: spacectl provider create-version --type=sendgrid

- name: Publish provider
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -60,4 +59,4 @@ jobs:
VERSION_NUMBER=${{ github.ref_name }}
VERSION_ID=$(jq -r --arg version "${VERSION_NUMBER#v}" '.versions[] | select(.number == $version) | .id' versions.json)
echo "Publishing ID: $VERSION_ID"
spacectl provider publish-version --version=$VERSION_ID
spacectl provider publish-version --version=$VERSION_ID
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.23
cache: true
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/octoenergy/terraform-provider-sendgrid

go 1.23.1
go 1.23

toolchain go1.21.3

require (
github.com/hashicorp/go-multierror v1.1.1
Expand Down

0 comments on commit 2ae7437

Please sign in to comment.