Skip to content

Commit 4fa2553

Browse files
authored
Merge pull request #7 from bytebase/feat/release
feat: add goreleaser and actions to publish the release
2 parents fc64fc2 + 4e17f44 commit 4fa2553

File tree

6 files changed

+153
-3
lines changed

6 files changed

+153
-3
lines changed

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This GitHub action can publish assets for release when a tag is created.
2+
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
3+
#
4+
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
5+
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
6+
# secret. If you would rather own your own GPG handling, please fork this action
7+
# or use an alternative one for key handling.
8+
#
9+
# You will need to pass the `--batch` flag to `gpg` in your signing step
10+
# in `goreleaser` to indicate this is being used in a non-interactive mode.
11+
#
12+
name: release
13+
on:
14+
push:
15+
tags:
16+
- 'v*'
17+
permissions:
18+
contents: write
19+
jobs:
20+
goreleaser:
21+
runs-on: ubuntu-latest
22+
steps:
23+
-
24+
name: Checkout
25+
uses: actions/checkout@v3
26+
-
27+
name: Unshallow
28+
run: git fetch --prune --unshallow
29+
-
30+
name: Set up Go
31+
uses: actions/setup-go@v3
32+
with:
33+
go-version-file: 'go.mod'
34+
cache: true
35+
-
36+
name: Import GPG key
37+
uses: crazy-max/ghaction-import-gpg@v5
38+
id: import_gpg
39+
with:
40+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
41+
passphrase: ${{ secrets.PASSPHRASE }}
42+
-
43+
name: Run GoReleaser
44+
uses: goreleaser/goreleaser-action@v3.2.0
45+
with:
46+
version: latest
47+
args: release --rm-dist
48+
env:
49+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
50+
# GitHub sets this automatically
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Visit https://goreleaser.com for documentation on how to customize this
2+
# behavior.
3+
before:
4+
hooks:
5+
# this is just an example and not a requirement for provider building/publishing
6+
- go mod tidy
7+
builds:
8+
- env:
9+
# goreleaser does not work with CGO, it could also complicate
10+
# usage by users in CI/CD systems like Terraform Cloud where
11+
# they are unable to install libraries.
12+
- CGO_ENABLED=0
13+
mod_timestamp: '{{ .CommitTimestamp }}'
14+
flags:
15+
- -trimpath
16+
ldflags:
17+
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
18+
goos:
19+
- freebsd
20+
- windows
21+
- linux
22+
- darwin
23+
goarch:
24+
- amd64
25+
- '386'
26+
- arm
27+
- arm64
28+
ignore:
29+
- goos: darwin
30+
goarch: '386'
31+
binary: '{{ .ProjectName }}_v{{ .Version }}'
32+
archives:
33+
- format: zip
34+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
35+
checksum:
36+
extra_files:
37+
- glob: 'terraform-registry-manifest.json'
38+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
39+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
40+
algorithm: sha256
41+
signs:
42+
- artifacts: checksum
43+
args:
44+
# if you are using this in a GitHub action or some other automated pipeline, you
45+
# need to pass the batch flag to indicate its not interactive.
46+
- "--batch"
47+
- "--local-user"
48+
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
49+
- "--output"
50+
- "${signature}"
51+
- "--detach-sign"
52+
- "${artifact}"
53+
release:
54+
extra_files:
55+
- glob: 'terraform-registry-manifest.json'
56+
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
57+
# If you want to manually examine the release before its live, uncomment this line:
58+
# draft: true
59+
changelog:
60+
skip: true

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2022-present Bytebase (Hong Kong) Limited.
2+
3+
Portions of this software are licensed as follows:
4+
5+
* All content that resides under the "enterprise/" and "frontend/src/enterprise/" directory of this repository, if that directory exists, is licensed under the license defined in "LICENSE.enterprise".
6+
* Content outside of the above mentioned directories or restrictions above is available under the "MIT Expat" license as defined below.
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy
9+
of this software and associated documentation files (the "Software"), to deal
10+
in the Software without restriction, including without limitation the rights
11+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
copies of the Software, and to permit persons to whom the Software is
13+
furnished to do so, subject to the following conditions:
14+
15+
The above copyright notice and this permission notice shall be included in all
16+
copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
SOFTWARE.

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ This repository is the Terraform provider for Bytebase.
77
### Prerequisites
88

99
- [Go](https://golang.org/doc/install) (1.19 or later)
10-
- [Air](https://github.com/cosmtrek/air#installation) (must use forked repo 87187cc). This is for backend live reload.
1110
- [Terraform](https://developer.hashicorp.com/terraform/downloads?product_intent=terraform) (1.3.5 or later)
11+
- [Bytebase](https://github.com/bytebase/bytebase)
1212

13-
### Prepare
13+
### Prepare Bytebase OpenAPI server
1414

1515
```bash
1616
# clone Bytebase to get the OpenAPI server
@@ -22,7 +22,7 @@ git clone git@github.com:bytebase/terraform-provider-bytebase.git
2222
```bash
2323
# start Bytebase OpenAPI server
2424
cd bytebase
25-
# check https://github.com/bytebase/bytebase for more information.
25+
# check https://github.com/bytebase/bytebase for starting the Bytebase server.
2626
air -c scripts/.air.toml
2727
```
2828

@@ -56,3 +56,11 @@ This will generate the doc template in the `docs` folder
5656
```bash
5757
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs --provider-name=terraform-provider-bytebase
5858
```
59+
60+
## Release
61+
62+
Follow [this doc](https://developer.hashicorp.com/terraform/registry/providers/publishing) to publish the provider.
63+
64+
Note:
65+
66+
We need to publish a new tag for a new version, the tag must be a valid [Semantic Version](https://semver.org/) **preceded with a v (for example, v1.2.3)**. There must not be a branch name with the same name as the tag.

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1

terraform-registry-manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"version": 1,
3+
"metadata": {
4+
"protocol_versions": ["5.0"]
5+
}
6+
}

0 commit comments

Comments
 (0)