Skip to content

Commit

Permalink
Merge pull request #21 from smutel/ImproveReleaseProcess
Browse files Browse the repository at this point in the history
Improve release process
  • Loading branch information
smutel authored Nov 25, 2020
2 parents 35dfbfa + 5c77e9e commit c38976c
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 10 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: Master

on:
push:
branches:
- master

jobs:
LintAndBuild:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go: [ '1.15.x' ]
steps:
- name: Checkout
uses: actions/[email protected]

- name: Unshallow
run: git fetch --prune --unshallow

- name: Lint
uses: reviewdog/[email protected]
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--config=.golangci.yml"

- name: Setup env
run: |
echo "GOPATH=$(dirname $GITHUB_WORKSPACE)" >> $GITHUB_ENV
echo "$(dirname $GITHUB_WORKSPACE)/bin" >> $GITHUB_PATH
mkdir -p "$(dirname $GITHUB_WORKSPACE)/src/github.com/smutel"
ln -sf "$GITHUB_WORKSPACE/" "$(dirname $GITHUB_WORKSPACE)/src/github.com/smutel/terraform-provider-netbox"
shell: bash

- name: Go installation
uses: actions/[email protected]
with:
go-version: ${{ matrix.go }}

- name: Build
run: |
cd "$(dirname $GITHUB_WORKSPACE)/src/github.com/smutel/terraform-provider-netbox"
make build
shell: bash
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
go: [ '1.15.x' ]
steps:
- name: Checkout
uses: actions/[email protected].3
uses: actions/[email protected].4

- name: Unshallow
run: git fetch --prune --unshallow

- name: Lint
uses: reviewdog/[email protected].0
uses: reviewdog/[email protected].1
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--config=.golangci.yml"
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
go: [ '1.15.x' ]
steps:
- name: Checkout
uses: actions/[email protected].3
uses: actions/[email protected].4

- name: Unshallow
run: git fetch --prune --unshallow
Expand All @@ -27,16 +27,21 @@ jobs:

- name: Import GPG key
id: import_gpg
uses: crazy-max/[email protected].1
uses: crazy-max/[email protected].2
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/[email protected]

- name: Generate CHANGELOG for this version
run: ./utils/getChangelogRelease CHANGELOG.md $TAG > RELEASE_CHANGELOG.md
env:
TAG: ${{ github.event.release.tag_name }}

- name: Run GoReleaser
uses: goreleaser/[email protected]
with:
version: latest
args: release --rm-dist
args: release --rm-dist --release-notes=RELEASE_CHANGELOG.md
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
54 changes: 54 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
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 Terraform Cloud 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:
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256
signs:
- artifacts: checksum
args:
# if you are using this is 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:
# Visit your project's GitHub Releases page to publish this release.
draft: true
changelog:
skip: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Lisence](https://img.shields.io/badge/license-ISC-informational?style=flat-square)](https://github.com/smutel/terraform-provider-netbox/blob/master/LICENSE)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-informational.svg?style=flat-square&logo=git)](https://conventionalcommits.org)
[![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)
[![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)
[![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)

Terraform provider for [Netbox.](https://netbox.readthedocs.io/en/stable/)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "terraform-provider-netbox",
"version": "1.0.0",
"version": "1.1.0",
"description": "Terraform provider for Netbox"
}
13 changes: 13 additions & 0 deletions utils/getChangelogRelease
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

CHANGELOG_FILE="$1"
VERSION="$2"

if [[ ${VERSION} =~ v* ]]; then
VERSION=${VERSION:1}
fi

START=$(grep -n "## \[${VERSION}\]" "${CHANGELOG_FILE}" | cut -d : -f 1)
END_VERSION=$(grep "## \[" "${CHANGELOG_FILE}" | cut -d"[" -f2 | cut -d"]" -f1 | grep -v 1.1.0 | head -1)
END=$(grep -n "## \[${END_VERSION}\]" ${CHANGELOG_FILE} | cut -d : -f 1)
cat "${CHANGELOG_FILE}" | tail -n +"$((START + 3))" | head -n "$((END - START - 4))"

0 comments on commit c38976c

Please sign in to comment.