|
| 1 | +# Releasing `terraform-provider-pcd` |
| 2 | + |
| 3 | +This provider is distributed through the [Terraform Registry](https://registry.terraform.io) |
| 4 | +at `platform9/pcd`. Releases are cut by pushing a semver tag; the |
| 5 | +[`release` workflow](.github/workflows/release.yml) builds every platform binary |
| 6 | +with [GoReleaser](https://goreleaser.com), signs the checksums with the org GPG |
| 7 | +key, and publishes a GitHub Release. The registry ingests that release |
| 8 | +automatically via its webhook. |
| 9 | + |
| 10 | +The steps below are split into **one-time setup** (done once for the repo) and |
| 11 | +**per-release** (done for every version). |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## One-time setup |
| 16 | + |
| 17 | +These are account/organisation actions that require repo-admin and a |
| 18 | +registry-connected GitHub account. They cannot be automated from CI and are |
| 19 | +**not** performed by any tooling in this repo — a human runs them once. |
| 20 | + |
| 21 | +### 1. Generate the signing GPG key |
| 22 | + |
| 23 | +The registry verifies every release's `SHA256SUMS` signature against a public |
| 24 | +key registered to the `platform9` namespace. Generate a dedicated key (RSA 4096, |
| 25 | +no expiry is fine for a service key): |
| 26 | + |
| 27 | +```sh |
| 28 | +gpg --full-generate-key # choose RSA/RSA, 4096 bits |
| 29 | +gpg --list-secret-keys --keyid-format=long # note the key ID / fingerprint |
| 30 | +``` |
| 31 | + |
| 32 | +Export both halves: |
| 33 | + |
| 34 | +```sh |
| 35 | +# Public key — this is uploaded to the Terraform Registry (step 3). |
| 36 | +gpg --armor --export "<KEY_ID>" > pcd-signing-key.pub.asc |
| 37 | + |
| 38 | +# Private key — this becomes the GPG_PRIVATE_KEY GitHub secret (step 2). |
| 39 | +gpg --armor --export-secret-keys "<KEY_ID>" > pcd-signing-key.priv.asc |
| 40 | +``` |
| 41 | + |
| 42 | +Keep the private key and its passphrase in the org secret manager. Do **not** |
| 43 | +commit either file (both are covered by the `.gitignore` `*.asc` rule). |
| 44 | + |
| 45 | +### 2. Add the GitHub Actions secrets |
| 46 | + |
| 47 | +In **Settings → Secrets and variables → Actions**, add: |
| 48 | + |
| 49 | +| Secret | Value | |
| 50 | +| --- | --- | |
| 51 | +| `GPG_PRIVATE_KEY` | contents of `pcd-signing-key.priv.asc` (the full ASCII-armored block) | |
| 52 | +| `PASSPHRASE` | the passphrase for that key | |
| 53 | + |
| 54 | +`GITHUB_TOKEN` is provided automatically by Actions — no need to add it. |
| 55 | + |
| 56 | +### 3. Register the provider on the Terraform Registry |
| 57 | + |
| 58 | +1. The repository must be **public** (registry requirement). If it is still |
| 59 | + private, change it in **Settings → General → Danger Zone → Change |
| 60 | + visibility**. Confirm with the code owners before doing this — it exposes the |
| 61 | + full history. |
| 62 | +2. Sign in to <https://registry.terraform.io> with a GitHub account that is a |
| 63 | + member of the `platform9` org. |
| 64 | +3. **Publish → Provider**, authorize the registry GitHub app for the |
| 65 | + `platform9` org, and select `terraform-provider-pcd`. The registry naming |
| 66 | + convention (`terraform-provider-<name>`) yields the address `platform9/pcd`, |
| 67 | + matching `main.go`'s `registry.terraform.io/platform9/pcd`. |
| 68 | +4. Under **Settings → GPG Keys** for the namespace, paste the public key from |
| 69 | + step 1 (`pcd-signing-key.pub.asc`). |
| 70 | + |
| 71 | +Once connected, the registry installs a webhook so future GitHub Releases are |
| 72 | +ingested automatically. |
| 73 | + |
| 74 | +### 4. Sanity-check the release config (optional but recommended) |
| 75 | + |
| 76 | +With [GoReleaser installed](https://goreleaser.com/install/) locally: |
| 77 | + |
| 78 | +```sh |
| 79 | +goreleaser check # validates .goreleaser.yml |
| 80 | +goreleaser release --snapshot --clean --skip=sign # dry-run a full build (no publish) |
| 81 | +``` |
| 82 | + |
| 83 | +The snapshot build drops artifacts in `dist/`; confirm it produces one zip per |
| 84 | +`goos/goarch` plus a `..._SHA256SUMS` file and the `..._manifest.json`. |
| 85 | + |
| 86 | +--- |
| 87 | + |
| 88 | +## Per-release |
| 89 | + |
| 90 | +### 1. Prepare the changelog |
| 91 | + |
| 92 | +Move the accumulated notes under `## [Unreleased]` in |
| 93 | +[`CHANGELOG.md`](CHANGELOG.md) into a new `## [X.Y.Z] - <date>` section and open |
| 94 | +a PR. Merge it to `main` before tagging. |
| 95 | + |
| 96 | +### 2. Tag and push |
| 97 | + |
| 98 | +From an up-to-date `main`: |
| 99 | + |
| 100 | +```sh |
| 101 | +git checkout main && git pull --ff-only |
| 102 | +git tag v0.1.0 # semver, MUST start with 'v' |
| 103 | +git push origin v0.1.0 |
| 104 | +``` |
| 105 | + |
| 106 | +Pushing the tag triggers the `release` workflow. |
| 107 | + |
| 108 | +### 3. Watch the release workflow |
| 109 | + |
| 110 | +```sh |
| 111 | +gh run watch # or: gh run list --workflow=release.yml |
| 112 | +``` |
| 113 | + |
| 114 | +On success there is a new **GitHub Release** for the tag containing: |
| 115 | + |
| 116 | +- `terraform-provider-pcd_X.Y.Z_<os>_<arch>.zip` for every platform |
| 117 | +- `terraform-provider-pcd_X.Y.Z_SHA256SUMS` and its `.sig` |
| 118 | +- `terraform-provider-pcd_X.Y.Z_manifest.json` |
| 119 | + |
| 120 | +### 4. Verify on the registry |
| 121 | + |
| 122 | +The registry usually ingests within a few minutes. Confirm the new version |
| 123 | +appears at <https://registry.terraform.io/providers/platform9/pcd>, then smoke-test |
| 124 | +consumption: |
| 125 | + |
| 126 | +```hcl |
| 127 | +terraform { |
| 128 | + required_providers { |
| 129 | + pcd = { |
| 130 | + source = "platform9/pcd" |
| 131 | + version = "X.Y.Z" |
| 132 | + } |
| 133 | + } |
| 134 | +} |
| 135 | +``` |
| 136 | + |
| 137 | +```sh |
| 138 | +terraform init # should download platform9/pcd X.Y.Z and verify its signature |
| 139 | +``` |
| 140 | + |
| 141 | +--- |
| 142 | + |
| 143 | +## Versioning |
| 144 | + |
| 145 | +Follow [Semantic Versioning](https://semver.org): patch for fixes, minor for |
| 146 | +new (backward-compatible) resources/data sources, major for breaking schema or |
| 147 | +behavior changes. Pre-1.0 (`v0.y.z`), breaking changes bump the minor. |
| 148 | + |
| 149 | +## Notes |
| 150 | + |
| 151 | +- The GitHub Actions used here are pinned to major-version tags to match |
| 152 | + [`test.yml`](.github/workflows/test.yml). Pin to commit SHAs if the org's |
| 153 | + supply-chain policy requires it. |
| 154 | +- Only tags matching `v*` release; branch pushes never publish. |
| 155 | +- `terraform-registry-manifest.json` declares Terraform **protocol 6.0** |
| 156 | + (the provider is built on `terraform-plugin-framework`); it is bundled into |
| 157 | + every release by GoReleaser so the registry records the protocol version. |
0 commit comments