Skip to content

Commit b1a2ef6

Browse files
committed
chore: better release process
1 parent 4c8d73a commit b1a2ef6

File tree

2 files changed

+95
-52
lines changed

2 files changed

+95
-52
lines changed

.github/workflows/release.yml

Lines changed: 70 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,70 +6,107 @@ on:
66
tags: ["v*"]
77

88
jobs:
9-
release:
10-
name: Release
9+
draft_release:
10+
name: Draft release
1111
runs-on: ubuntu-latest
1212
outputs:
13-
upload_url: ${{ steps.create_release.outputs.upload_url }}
13+
tag: ${{ steps.get_tag.outputs.tag }}
14+
release_id: ${{ steps.create_draft_release.outputs.release_id }}
15+
upload_url: ${{ steps.create_draft_release.outputs.upload_url }}
1416
steps:
15-
- name: Create Release
16-
id: create_release
17-
uses: actions/create-release@v1
17+
- name: Get tag
18+
id: get_tag
19+
shell: bash
20+
# Github actions does not make getting the tag name easy...
21+
run: echo "::set-output name=tag::${GITHUB_REF#refs\/tags\/}"
22+
23+
# actions/create_release official action returns 'untagged-XXX' as release tag (bug).
24+
- name: Create draft Release
25+
id: create_draft_release
26+
shell: bash
1827
env:
28+
tag: ${{ steps.get_tag.outputs.tag }}
1929
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20-
with:
21-
tag_name: ${{ github.ref }}
22-
release_name: Release ${{ github.ref }}
23-
draft: false
24-
prerelease: false
30+
run: |
31+
RESULT=$(curl -sfL -H "Authorization: token ${GITHUB_TOKEN}" -XPOST --data '{"tag_name":"${{ env.tag }}","name":"${{ env.tag }}","draft":true}' https://api.github.com/repos/${{ github.repository }}/releases)
32+
33+
RELEASE_ID=$(echo $RESULT | jq -r .id)
34+
UPLOAD_URL=$(echo $RESULT | jq -r .upload_url)
35+
36+
echo "::set-output name=release_id::${RELEASE_ID}"
37+
echo "::set-output name=upload_url::${UPLOAD_URL}"
2538
2639
assets:
2740
name: Assets
28-
needs: release
41+
needs: draft_release
2942
strategy:
30-
fail-fast: false
43+
fail-fast: true
3144
matrix:
32-
arch: [amd64]
33-
os: [ubuntu-latest, macos-latest, windows-latest]
34-
include:
35-
- os: ubuntu-latest
36-
goos: linux
37-
- os: macos-latest
38-
goos: darwin
39-
- os: windows-latest
40-
goos: windows
41-
runs-on: ${{ matrix.os }}
45+
arch: [amd64, 386, arm]
46+
os: [linux, darwin, windows, freebsd, openbsd]
47+
exclude:
48+
- os: darwin
49+
arch: 386
50+
- os: darwin
51+
arch: arm
52+
- os: windows
53+
arch: arm
54+
- os: openbsd
55+
arch: arm
56+
runs-on: ubuntu-latest
4257
env:
43-
asset: terraform-provider-argocd_${{ github.ref }}_${{ matrix.goos }}_${{ matrix.arch }}
58+
asset: terraform-provider-argocd_${{ needs.draft_release.outputs.tag }}_${{ matrix.os }}_${{ matrix.arch }}.gz
59+
asset_build: terraform-provider-argocd_${{ needs.draft_release.outputs.tag }}
60+
asset_gzip_suffix: _${{ matrix.os }}_${{ matrix.arch }}.gz
61+
upload_url: ${{ needs.draft_release.outputs.upload_url }}
4462
steps:
4563
- name: Checkout code
4664
uses: actions/checkout@v2
65+
4766
- uses: actions/setup-go@v1
4867
with:
4968
go-version: 1.14
50-
id: go
69+
5170
- name: Restore Go cache
5271
uses: actions/cache@v1
5372
with:
5473
path: ~/go/pkg/mod
55-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
74+
key: ${{ matrix.os }}-${{ matrix.arch }}-go-${{ hashFiles('**/go.sum') }}
5675
restore-keys: |
57-
${{ runner.os }}-go-
76+
${{ matrix.os }}-${{ matrix.arch }}-go-
5877
59-
- name: Build ${{ matrix.goos }}-${{ matrix.arch }}
78+
- name: Build ${{ matrix.os }}-${{ matrix.arch }}
6079
env:
6180
GOLDFLAGS: "-s -w"
6281
GOARCH: ${{ matrix.arch }}
63-
GOOS: ${{ matrix.goos }}
64-
run: go build -o ${{ env.asset }}
82+
GOOS: ${{ matrix.os }}
83+
run: |
84+
go build -o ${{ env.asset_build }}
85+
gzip --name --suffix ${{ env.asset_gzip_suffix }} ${{ env.asset_build }}
6586
6687
- name: Upload Release Asset
67-
id: upload-release-asset
6888
uses: actions/upload-release-asset@v1
6989
env:
7090
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7191
with:
72-
upload_url: ${{ needs.release.outputs.upload_url }}
92+
upload_url: ${{ env.upload_url }}
7393
asset_path: ./${{ env.asset }}
7494
asset_name: ${{ env.asset }}
75-
asset_content_type: application/octet-stream
95+
asset_content_type: application/gzip
96+
97+
publish_release:
98+
name: Publish release
99+
runs-on: ubuntu-latest
100+
needs:
101+
- assets
102+
- draft_release
103+
env:
104+
release_id: ${{ needs.draft_release.outputs.release_id }}
105+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
steps:
107+
- name: Publish release
108+
shell: bash
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
run: |
112+
curl -sfL -H "Authorization: token ${GITHUB_TOKEN}" -XPATCH --data '{"draft":false}' https://api.github.com/repos/${{ github.repository }}/releases/${{ env.release_id }}

README.md

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
## Requirements
88

9-
- [Terraform](https://www.terraform.io/downloads.html) 0.12.x
10-
- [Go](https://golang.org/doc/install) 1.14+
9+
- [Terraform](https://www.terraform.io/downloads.html) 0.12.24+
1110

1211
---
1312

@@ -34,21 +33,17 @@ In these cases, not only the readability of your Terraform plan will worsen, but
3433

3534
---
3635

37-
## Building
36+
## Installation
3837

39-
Clone the repository within your `GOPATH`
40-
41-
```sh
42-
mkdir -p $GOPATH/src/github.com/oboukili; cd $GOPATH/src/github.com/oboukili
43-
git clone [email protected]:oboukili/terraform-provider-argocd
44-
```
38+
* **From binary releases**:
39+
Get the [latest release](https://github.com/oboukili/terraform-provider-argocd/releases/latest), or adapt and run the following:
40+
```shell script
41+
curl -LO https://github.com/oboukili/terraform-provider-argocd/releases/download/v0.1.0/terraform-provider-argocd_v0.1.0_linux_amd64.gz
42+
gunzip -N terraform-provider-argocd_v0.1.0_linux_amd64.gz
43+
mv terraform-provider-argocd_v0.1.0 ~/.terraform.d/plugins/linux_amd64/
44+
```
4545

46-
Then build the provider
47-
48-
```sh
49-
cd $GOPATH/src/github.com/oboukili/terraform-provider-argocd
50-
make build
51-
```
46+
* **From source**: Follow [the 'contributing' build instructions](https://github.com/oboukili/terraform-provider-argocd#building).
5247

5348
## Usage
5449

@@ -145,15 +140,26 @@ resource "argocd_project_token" "secret" {
145140
}
146141
```
147142

148-
## Developing the Provider
143+
---
144+
145+
## Contributing
149146

150147
Contributions are welcome! You'll first need a working installation of [Go 1.14+](http://www.golang.org). Just as a reminder. you will also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH).
151148

152-
To compile the provider, run `make build`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
149+
### Building
150+
151+
Clone the repository within your `GOPATH`
153152

154153
```sh
155-
make build
156-
$GOPATH/bin/terraform-provider-argocd
154+
mkdir -p $GOPATH/src/github.com/oboukili; cd $GOPATH/src/github.com/oboukili
155+
git clone [email protected]:oboukili/terraform-provider-argocd
156+
```
157+
158+
Then build the provider
159+
160+
```sh
161+
cd $GOPATH/src/github.com/oboukili/terraform-provider-argocd
162+
go build
157163
```
158164

159165
### Running tests

0 commit comments

Comments
 (0)