-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from hashicorp/ci-release
CI and release process
- Loading branch information
Showing
3 changed files
with
253 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
version: 2.1 | ||
|
||
orbs: | ||
win: circleci/[email protected] | ||
|
||
commands: | ||
go_build: | ||
steps: | ||
- run: go build ./... | ||
go_test: | ||
steps: | ||
- run: go test -v ./... | ||
|
||
jobs: | ||
winbuild: | ||
executor: | ||
name: win/default | ||
steps: | ||
- checkout | ||
- go_build | ||
wintest: | ||
executor: | ||
name: win/default | ||
steps: | ||
- checkout | ||
- go_test | ||
|
||
"go112_build": | ||
docker: | ||
- image: circleci/golang:1.12 | ||
steps: | ||
- checkout | ||
- go_build | ||
"go112_test": | ||
docker: | ||
- image: circleci/golang:1.12 | ||
steps: | ||
- checkout | ||
- go_build | ||
|
||
"go114_build": | ||
docker: | ||
- image: circleci/golang:1.14 | ||
steps: | ||
- checkout | ||
- go_build | ||
"go114_test": | ||
docker: | ||
- image: circleci/golang:1.14 | ||
parameters: | ||
test_results: | ||
type: string | ||
default: /tmp/test-results | ||
steps: | ||
- checkout | ||
- go_test | ||
"go114_vet": | ||
docker: | ||
- image: circleci/golang:1.14 | ||
steps: | ||
- checkout | ||
- run: go vet ./... | ||
"go114_fmt": | ||
docker: | ||
- image: circleci/golang:1.14 | ||
steps: | ||
- checkout | ||
- run: gofmt -s -l . | ||
"go114_release": | ||
docker: | ||
- image: circleci/golang:1.14 | ||
steps: | ||
- add_ssh_keys: | ||
fingerprints: | ||
- "db:cf:97:b8:d6:ac:86:74:96:e1:54:e4:bc:27:2b:d0" | ||
- checkout | ||
- run: ./scripts/release/release.sh | ||
|
||
workflows: | ||
version: 2 | ||
pr: | ||
jobs: | ||
- winbuild | ||
- wintest | ||
- "go112_build" | ||
- "go112_test" | ||
- "go114_build" | ||
- "go114_test": | ||
requires: | ||
- "go114_build" | ||
- "go114_vet": | ||
requires: | ||
- "go114_build" | ||
- "go114_fmt": | ||
requires: | ||
- "go114_build" | ||
release: | ||
jobs: | ||
- winbuild | ||
- wintest | ||
- "go112_build" | ||
- "go112_test" | ||
- "go114_build" | ||
- "go114_test": | ||
requires: | ||
- "go114_build" | ||
- "go114_vet": | ||
requires: | ||
- "go114_build" | ||
- "go114_fmt": | ||
requires: | ||
- "go114_build" | ||
- trigger-release: | ||
filters: | ||
branches: | ||
only: | ||
- master | ||
type: approval | ||
- "go114_release": | ||
filters: | ||
branches: | ||
only: | ||
- master | ||
requires: | ||
- trigger-release | ||
- "go114_test" | ||
- "go114_vet" | ||
- "go114_fmt" | ||
- winbuild | ||
- wintest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
# This script rewrites [GH-nnnn]-style references in the CHANGELOG.md file to | ||
# be Markdown links to the given github issues. | ||
# | ||
# This is run during releases so that the issue references in all of the | ||
# released items are presented as clickable links, but we can just use the | ||
# easy [GH-nnnn] shorthand for quickly adding items to the "Unrelease" section | ||
# while merging things between releases. | ||
|
||
set -e | ||
|
||
if [[ ! -f CHANGELOG.md ]]; then | ||
echo "ERROR: CHANGELOG.md not found in pwd." | ||
echo "Please run this from the root of the repository" | ||
exit 1 | ||
fi | ||
|
||
if [[ `uname` == "Darwin" ]]; then | ||
echo "Using BSD sed" | ||
SED="sed -i.bak -E -e" | ||
else | ||
echo "Using GNU sed" | ||
SED="sed -i.bak -r -e" | ||
fi | ||
|
||
$SED 's/GH-([0-9]+)/\[#\1\]\(https:\/\/github.com\/hashicorp\/terraform-plugin-sdk\/issues\/\1\)/g' -e 's/\[\[#(.+)([0-9])\)]$/(\[#\1\2))/g' CHANGELOG.md | ||
|
||
rm CHANGELOG.md.bak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
# release.sh will: | ||
# 1. Modify changelog | ||
# 2. Run changelog links script | ||
# 3. Modify version in tfinstall/version.go | ||
# 4. Commit and push changes | ||
# 5. Create a Git tag | ||
|
||
function pleaseUseGNUsed { | ||
echo "Please install GNU sed to your PATH as 'sed'." | ||
exit 1 | ||
} | ||
|
||
function init { | ||
sed --version > /dev/null || pleaseUseGNUsed | ||
|
||
DATE=`date '+%B %d, %Y'` | ||
START_DIR=`pwd` | ||
|
||
if [ "$CI" = true ] ; then | ||
GPG_KEY_ID=C6DC8F8C8E78B36A | ||
gpg --batch --import <(echo -e "${GPG_PUBLIC_KEY}") | ||
gpg --batch --import <(echo -e "${GPG_PRIVATE_KEY}") | ||
git config --global user.email [email protected] | ||
git config --global user.name "Terraform SDK CircleCI" | ||
fi | ||
|
||
TARGET_VERSION="$(getTargetVersion)" | ||
} | ||
|
||
semverRegex='\([0-9]\+\.[0-9]\+\.[0-9]\+\)\(-\?\)\([0-9a-zA-Z.]\+\)\?' | ||
|
||
function getTargetVersion { | ||
# parse target version from CHANGELOG | ||
sed -n 's/^# '"$semverRegex"' (Unreleased)$/\1\2\3/p' CHANGELOG.md || \ | ||
(echo "\nTarget version not found in changelog, exiting" && \ | ||
exit 1) | ||
} | ||
|
||
function modifyChangelog { | ||
sed -i "s/$TARGET_VERSION (Unreleased)$/$TARGET_VERSION ($DATE)/" CHANGELOG.md | ||
} | ||
|
||
function changelogLinks { | ||
./scripts/release/changelog_links.sh | ||
} | ||
|
||
function changelogMain { | ||
printf "Modifying Changelog..." | ||
modifyChangelog | ||
printf "ok!\n" | ||
printf "Running Changelog Links..." | ||
changelogLinks | ||
printf "ok!\n" | ||
} | ||
|
||
function modifyVersionFiles { | ||
sed -i "s/const Version =.*/const Version = \"${TARGET_VERSION}\"/" tfinstall/version.go | ||
} | ||
|
||
function commitChanges { | ||
git add CHANGELOG.md | ||
modifyVersionFiles | ||
git add tfinstall/version.go | ||
|
||
if [ "$CI" = true ] ; then | ||
git commit --gpg-sign="${GPG_KEY_ID}" -m "v${TARGET_VERSION} [skip ci]" | ||
git tag -a -m "v${TARGET_VERSION}" -s -u "${GPG_KEY_ID}" "v${TARGET_VERSION}" | ||
else | ||
git commit -m "v${TARGET_VERSION} [skip ci]" | ||
git tag -a -m "v${TARGET_VERSION}" -s "v${TARGET_VERSION}" | ||
fi | ||
|
||
git push origin "${CIRCLE_BRANCH}" | ||
git push origin "v${TARGET_VERSION}" | ||
} | ||
|
||
function commitMain { | ||
printf "Committing Changes..." | ||
commitChanges | ||
printf "ok!\n" | ||
} | ||
|
||
function main { | ||
init | ||
changelogMain | ||
commitMain | ||
} | ||
|
||
main |