Skip to content

Commit 5c77e9e

Browse files
committed
ci: Improve release process
1 parent 35dfbfa commit 5c77e9e

File tree

7 files changed

+128
-10
lines changed

7 files changed

+128
-10
lines changed

.github/workflows/master.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: Master
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
LintAndBuild:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
go: [ '1.15.x' ]
16+
steps:
17+
- name: Checkout
18+
uses: actions/[email protected]
19+
20+
- name: Unshallow
21+
run: git fetch --prune --unshallow
22+
23+
- name: Lint
24+
uses: reviewdog/[email protected]
25+
with:
26+
github_token: ${{ secrets.github_token }}
27+
golangci_lint_flags: "--config=.golangci.yml"
28+
29+
- name: Setup env
30+
run: |
31+
echo "GOPATH=$(dirname $GITHUB_WORKSPACE)" >> $GITHUB_ENV
32+
echo "$(dirname $GITHUB_WORKSPACE)/bin" >> $GITHUB_PATH
33+
mkdir -p "$(dirname $GITHUB_WORKSPACE)/src/github.com/smutel"
34+
ln -sf "$GITHUB_WORKSPACE/" "$(dirname $GITHUB_WORKSPACE)/src/github.com/smutel/terraform-provider-netbox"
35+
shell: bash
36+
37+
- name: Go installation
38+
uses: actions/[email protected]
39+
with:
40+
go-version: ${{ matrix.go }}
41+
42+
- name: Build
43+
run: |
44+
cd "$(dirname $GITHUB_WORKSPACE)/src/github.com/smutel/terraform-provider-netbox"
45+
make build
46+
shell: bash

.github/workflows/pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ jobs:
1616
go: [ '1.15.x' ]
1717
steps:
1818
- name: Checkout
19-
uses: actions/[email protected].3
19+
uses: actions/[email protected].4
2020

2121
- name: Unshallow
2222
run: git fetch --prune --unshallow
2323

2424
- name: Lint
25-
uses: reviewdog/[email protected].0
25+
uses: reviewdog/[email protected].1
2626
with:
2727
github_token: ${{ secrets.github_token }}
2828
golangci_lint_flags: "--config=.golangci.yml"

.github/workflows/release.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
go: [ '1.15.x' ]
1616
steps:
1717
- name: Checkout
18-
uses: actions/[email protected].3
18+
uses: actions/[email protected].4
1919

2020
- name: Unshallow
2121
run: git fetch --prune --unshallow
@@ -27,16 +27,21 @@ jobs:
2727

2828
- name: Import GPG key
2929
id: import_gpg
30-
uses: crazy-max/[email protected].1
30+
uses: crazy-max/[email protected].2
3131
with:
3232
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
3333
passphrase: ${{ secrets.PASSPHRASE }}
34-
-
35-
name: Run GoReleaser
36-
uses: goreleaser/[email protected]
34+
35+
- name: Generate CHANGELOG for this version
36+
run: ./utils/getChangelogRelease CHANGELOG.md $TAG > RELEASE_CHANGELOG.md
37+
env:
38+
TAG: ${{ github.event.release.tag_name }}
39+
40+
- name: Run GoReleaser
41+
uses: goreleaser/[email protected]
3742
with:
3843
version: latest
39-
args: release --rm-dist
44+
args: release --rm-dist --release-notes=RELEASE_CHANGELOG.md
4045
env:
4146
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
4247
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
37+
algorithm: sha256
38+
signs:
39+
- artifacts: checksum
40+
args:
41+
# if you are using this is a GitHub action or some other automated pipeline, you
42+
# need to pass the batch flag to indicate its not interactive.
43+
- "--batch"
44+
- "--local-user"
45+
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
46+
- "--output"
47+
- "${signature}"
48+
- "--detach-sign"
49+
- "${artifact}"
50+
release:
51+
# Visit your project's GitHub Releases page to publish this release.
52+
draft: true
53+
changelog:
54+
skip: true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Lisence](https://img.shields.io/badge/license-ISC-informational?style=flat-square)](https://github.com/smutel/terraform-provider-netbox/blob/master/LICENSE)
44
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-informational.svg?style=flat-square&logo=git)](https://conventionalcommits.org)
5-
[![Build Status](https://img.shields.io/github/workflow/status/smutel/terraform-provider-netbox/checks/master?style=flat-square&logo=github-actions)](https://github.com/smutel/terraform-provider-netbox/actions)
5+
[![Build Status](https://img.shields.io/github/workflow/status/smutel/terraform-provider-netbox/Master/master?style=flat-square&logo=github-actions)](https://github.com/smutel/terraform-provider-netbox/actions)
66
[![Go Report Card](https://goreportcard.com/badge/github.com/smutel/terraform-provider-netbox?style=flat-square)](https://goreportcard.com/report/github.com/smutel/terraform-provider-netbox)
77

88
Terraform provider for [Netbox.](https://netbox.readthedocs.io/en/stable/)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "terraform-provider-netbox",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Terraform provider for Netbox"
55
}

utils/getChangelogRelease

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
CHANGELOG_FILE="$1"
4+
VERSION="$2"
5+
6+
if [[ ${VERSION} =~ v* ]]; then
7+
VERSION=${VERSION:1}
8+
fi
9+
10+
START=$(grep -n "## \[${VERSION}\]" "${CHANGELOG_FILE}" | cut -d : -f 1)
11+
END_VERSION=$(grep "## \[" "${CHANGELOG_FILE}" | cut -d"[" -f2 | cut -d"]" -f1 | grep -v 1.1.0 | head -1)
12+
END=$(grep -n "## \[${END_VERSION}\]" ${CHANGELOG_FILE} | cut -d : -f 1)
13+
cat "${CHANGELOG_FILE}" | tail -n +"$((START + 3))" | head -n "$((END - START - 4))"

0 commit comments

Comments
 (0)