-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from atlassian/release-from-bitbucket
Release from bitbucket
- Loading branch information
Showing
32 changed files
with
590 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Terraform Provider release workflow. | ||
name: Release | ||
|
||
# This GitHub action creates a release when a tag that matches the pattern | ||
# "v*" (e.g. v0.1.0) is created. | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
# Releases need permissions to read and write the repository contents. | ||
# GitHub considers creating releases and uploading assets as writing contents. | ||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
# Allow goreleaser to access older tag information. | ||
fetch-depth: 0 | ||
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | ||
with: | ||
go-version-file: 'go.mod' | ||
cache: true | ||
- name: Import GPG key | ||
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0 | ||
id: import_gpg | ||
with: | ||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
passphrase: ${{ secrets.PASSPHRASE }} | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0 | ||
with: | ||
args: release --clean | ||
env: | ||
# GitHub sets the GITHUB_TOKEN secret automatically. | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Visit https://goreleaser.com for documentation on how to customize this | ||
# behavior. | ||
version: 2 | ||
before: | ||
hooks: | ||
# this is just an example and not a requirement for provider building/publishing | ||
- go mod tidy | ||
builds: | ||
- env: | ||
# goreleaser does not work with CGO, it could also complicate | ||
# usage by users in CI/CD systems like HCP Terraform where | ||
# they are unable to install libraries. | ||
- CGO_ENABLED=0 | ||
mod_timestamp: '{{ .CommitTimestamp }}' | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}' | ||
goos: | ||
- freebsd | ||
- windows | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- '386' | ||
- arm | ||
- arm64 | ||
ignore: | ||
- goos: darwin | ||
goarch: '386' | ||
binary: '{{ .ProjectName }}_v{{ .Version }}' | ||
archives: | ||
- format: zip | ||
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' | ||
checksum: | ||
extra_files: | ||
- glob: 'terraform-registry-manifest.json' | ||
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' | ||
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' | ||
algorithm: sha256 | ||
signs: | ||
- artifacts: checksum | ||
args: | ||
# if you are using this in a GitHub action or some other automated pipeline, you | ||
# need to pass the batch flag to indicate its not interactive. | ||
- "--batch" | ||
- "--local-user" | ||
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key | ||
- "--output" | ||
- "${signature}" | ||
- "--detach-sign" | ||
- "${artifact}" | ||
release: | ||
extra_files: | ||
- glob: 'terraform-registry-manifest.json' | ||
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' | ||
# If you want to manually examine the release before its live, uncomment this line: | ||
# draft: true | ||
changelog: | ||
disable: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ The process to run the provider in a local environment requires the following st | |
|
||
### 1. Requirements | ||
|
||
This project requires the following programs to be installed on your computer, and their main executables to be | ||
This project requires the following programs to be installed on your computer, and their main executables to be | ||
available in your PATH: | ||
|
||
- [Go](https://golang.org/doc/install) 1.22 (or higher, to build the provider plugin) | ||
|
@@ -49,12 +49,12 @@ available in your PATH: | |
### 2. Cloning the repository | ||
|
||
```bash | ||
git clone git@bitbucket.org:jira-service-management/terraform-provider-atlassian-operations.git | ||
git clone git@github.com:atlassian/terraform-provider-atlassian-operations.git | ||
``` | ||
|
||
### 3. Compiling & Installing | ||
_Make sure that go is already installed and the command is available on your path. | ||
Check the [Go Documentation](https://go.dev/wiki/SettingGOPATH) for instructions on how to add the | ||
Check the [Go Documentation](https://go.dev/wiki/SettingGOPATH) for instructions on how to add the | ||
go executable to your path, if not already added._ | ||
|
||
While in the project directory, run the following commands: | ||
|
@@ -70,7 +70,7 @@ go env GOPATH | |
``` | ||
|
||
### 4. Setting local overrides | ||
This step is required for Terraform to use the plugin executable that you just compiled, | ||
This step is required for Terraform to use the plugin executable that you just compiled, | ||
instead of the one downloaded from the Terraform Registry. | ||
|
||
* For macOS & Linux: Create a file called `.terraformrc` in your `$HOME` directory | ||
|
@@ -80,9 +80,9 @@ Add the following content to the file: | |
|
||
```hcl | ||
provider_installation { | ||
# "/Users/<YOUR_USERNAME>/go/bin" is the path to the compiled provider ($GOPATH/bin). | ||
# Change it accordingly if your configuration is different. | ||
# "/Users/<YOUR_USERNAME>/go/bin" is the path to the compiled provider ($GOPATH/bin). | ||
# Change it accordingly if your configuration is different. | ||
dev_overrides { | ||
# Replace <YOUR_USERNAME> with your username | ||
"registry.terraform.io/atlassian/atlassian-operations" = "/Users/<YOUR_USERNAME>/go/bin" | ||
|
@@ -101,27 +101,27 @@ provider_installation { | |
|
||
```hcl | ||
terraform { | ||
required_providers { | ||
atlassian-operations = { | ||
source = "registry.terraform.io/atlassian/atlassian-operations" | ||
} | ||
required_providers { | ||
atlassian-operations = { | ||
source = "registry.terraform.io/atlassian/atlassian-operations" | ||
} | ||
} | ||
provider "atlassian-operations" { | ||
cloud_id = "<YOUR_CLOUD_ID>" | ||
domain_name="<YOUR_DOMAIN>" // e.g. domain.atlassian.net | ||
email_address = "<YOUR_EMAIL_ADDRESS>" // e.g. [email protected] | ||
token = "<YOUR_TOKEN_HERE>" // e.g. API token created in Atlassian account settings | ||
} | ||
data "atlassian-operations_user" "example" { | ||
email_address = "[email protected]" | ||
} | ||
output "example" { | ||
value = "data.atlassian-operations_user.example" | ||
} | ||
} | ||
provider "atlassian-operations" { | ||
cloud_id = "<YOUR_CLOUD_ID>" | ||
domain_name="<YOUR_DOMAIN>" // e.g. domain.atlassian.net | ||
email_address = "<YOUR_EMAIL_ADDRESS>" // e.g. [email protected] | ||
token = "<YOUR_TOKEN_HERE>" // e.g. API token created in Atlassian account settings | ||
} | ||
data "atlassian-operations_user" "example" { | ||
email_address = "[email protected]" | ||
} | ||
output "example" { | ||
value = "data.atlassian-operations_user.example" | ||
} | ||
``` | ||
|
||
Instead of providing values in the _provider_ block directly, you can also set the following environment variables: | ||
|
@@ -133,13 +133,13 @@ export ATLASSIAN_OPS_API_EMAIL_ADDRESS=YOUR_EMAIL_ADDRESS | |
export ATLASSIAN_OPS_API_TOKEN=YOUR_TOKEN | ||
``` | ||
|
||
_If you do not want to debug the provider with a debugger, and would like to simply execute the Terraform file you | ||
_If you do not want to debug the provider with a debugger, and would like to simply execute the Terraform file you | ||
just created, you can skip the next part and jump directly to [Running Without Debugging](#53-running-without-debugging)_ | ||
|
||
#### 5.2. Enable Debugging | ||
|
||
To enable debugging for the provider and make it connect to Delve before carrying on with the execution of the | ||
instructions in the .tf file, you need to set the `debug` flag to `true`, via altering the `flag.BoolVar` statement in | ||
To enable debugging for the provider and make it connect to Delve before carrying on with the execution of the | ||
instructions in the .tf file, you need to set the `debug` flag to `true`, via altering the `flag.BoolVar` statement in | ||
the `main.tf` file: | ||
|
||
```go | ||
|
@@ -148,25 +148,25 @@ import "flag" | |
// ... | ||
|
||
func main() { | ||
var debug bool | ||
var debug bool | ||
|
||
flag.BoolVar(&debug, "debug", true, "set to true to run the provider with support for debuggers like delve") | ||
flag.Parse() | ||
flag.BoolVar(&debug, "debug", true, "set to true to run the provider with support for debuggers like delve") | ||
flag.Parse() | ||
|
||
// Rest of the main.go file | ||
// Rest of the main.go file | ||
} | ||
``` | ||
This will make the provider executable pause the execution and wait for a debugger to connect before proceeding. | ||
|
||
With the default configuration, the provider binary is compiled **without debug information**. | ||
To include the necessary debug information within the library, you need to build the provider with the | ||
With the default configuration, the provider binary is compiled **without debug information**. | ||
To include the necessary debug information within the library, you need to build the provider with the | ||
-gcflags="all=-N -l" flag. Afterward, you can run and attach the process to the Delve debugger with the `dlv` command. | ||
|
||
```bash | ||
go build -gcflags="all=-N -l" . | ||
dlv exec --accept-multiclient --continue --headless ./terraform_provider_jsm_ops -- -debug | ||
``` | ||
_Most IDEs do building with debug flags and attaching to Delve debugger in the background automatically when the | ||
_Most IDEs do building with debug flags and attaching to Delve debugger in the background automatically when the | ||
debugger is run from within their UI._ | ||
|
||
When the provider executable is run with this configuration, it will output a message similar to the following: | ||
|
@@ -181,7 +181,7 @@ Provider started. To attach Terraform CLI, set the TF_REATTACH_PROVIDERS environ | |
TF_REATTACH_PROVIDERS='{"registry.terraform.io/atlassian/atlassian-operations":{"Protocol":"grpc","ProtocolVersion":6,"Pid":47822,"Test":true,"Addr":{"Network":"unix","String":"/var/folders/5n/wcvl0l8d4nx15qz3jy9jn7wh0000gn/T/plugin3023012805"}}}' | ||
``` | ||
Simply follow the instructions as they are prompted. Either set the `TF_REATTACH_PROVIDERS` environment variable in | ||
Simply follow the instructions as they are prompted. Either set the `TF_REATTACH_PROVIDERS` environment variable in | ||
your terminal, or prepend it to your every Terraform command. | ||
* Set the environment variable: | ||
|
@@ -195,7 +195,7 @@ TF_REATTACH_PROVIDERS=<_PROMPTED_STRING_AT_THE_DEBUG_CONSOLE_> terraform plan | |
TF_REATTACH_PROVIDERS=<_PROMPTED_STRING_AT_THE_DEBUG_CONSOLE_> terraform apply | ||
``` | ||
More information on how to use Delve with Terraform can be found in the | ||
More information on how to use Delve with Terraform can be found in the | ||
[Terraform documentation](https://developer.hashicorp.com/terraform/plugin/debugging). | ||
### 6. Running Acceptance Tests | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,11 +25,23 @@ definitions: | |
image: golangci/golangci-lint:v1.31.0 | ||
script: | ||
- golangci-lint run -v | ||
- step: &replicate-to-github | ||
name: Replicate main branch to GitHub | ||
script: | ||
- git fetch --unshallow && git checkout main && git pull | ||
- git remote rename origin bitbucket | ||
- git remote add origin [email protected]:atlassian/terraform-provider-atlassian-operations.git | ||
- git pull --rebase | ||
- git checkout -b release-from-bitbucket | ||
- git push --set-upstream origin release-from-bitbucket --force | ||
|
||
pipelines: | ||
default: | ||
- parallel: | ||
- step: *build | ||
custom: | ||
replicate-to-github: | ||
- step: *replicate-to-github | ||
pull-requests: | ||
'**': | ||
- step: *test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.