Skip to content

Commit

Permalink
Automate draft release creation with Goreleaser
Browse files Browse the repository at this point in the history
Go releaser builds the release artefacts and creates a draft release on Github
  • Loading branch information
doodlesbykumbi authored Apr 1, 2021
1 parent 25b8ced commit a96dc6d
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build Go package (release)
run: ./build
- name: Build Go package (release snapshot)
run: ./build --snapsot
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Build Go package (snapshot)
run: ./build --snapshot
Expand Down
12 changes: 9 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ nfpms:
- file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Arch }}"
vendor: CyberArk
homepage: https://github.com/cyberark/summon
maintainer: Dustin Collins <dustin.collins@cyberark.com>
maintainer: Conjur Maintainers <conj_maintainers@cyberark.com>

description: CLI that provides on-demand secrets access for common DevOps tools.
recommends:
Expand All @@ -74,8 +74,14 @@ nfpms:
formats:
- deb
- rpm
- apk
bindir: /usr/local/bin

dist: ./dist/goreleaser

release:
disable: true
prerelease: auto
disable: false
draft: true
extra_files:
- glob: LICENSE
- glob: CHANGELOG.md
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

### Added
- Adds apk package to the release artefacts.
[cyberark/summon#209](https://github.com/cyberark/summon/issues/209)

## [0.8.3] - 2020-09-25

### Added
Expand Down
24 changes: 12 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ To build versions for Linux, macOS and Windows:
./build
```

Binaries will be placed in `dist/`.
Binaries will be placed in `dist/goreleaser`.

### Running the project from source

Expand Down Expand Up @@ -79,9 +79,9 @@ The following checklist should be followed when creating a release:
- [ ] Retrieve artifacts generated by jenkins to perform smoke tests
- Note: You can manually [`Build`](./build) the release. Output is placed in the `dist` folder
- [ ] Binaries for smoke testing are found in the following directories
- Linux: `dist/summon-linux_linux_amd64`
- MacOS: `dist/summon_darwin_amd64`
- Windows: `dist/summon_windows_amd64`
- Linux: `dist/goreleaser/summon-linux_linux_amd64`
- MacOS: `dist/goreleaser/summon_darwin_amd64`
- Windows: `dist/goreleaser/summon_windows_amd64`

- [ ] Create a draft release:
- [ ] Create an [annotated tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging#_annotated_tags)
Expand All @@ -91,19 +91,19 @@ The following checklist should be followed when creating a release:
- [ ] Name the release the same as the tag.
- [ ] Include in the release notes all changes from CHANGELOG that are being released.
- [ ] Attach the relevant assets to the release, generated previously by `./build`:
- [ ] Attach `dist/summon-darwin-amd64.tar.gz` to release.
- [ ] Attach `dist/summon-linux-amd64.tar.gz` to release.
- [ ] Attach `dist/summon-windows-amd64.tar.gz` to release.
- [ ] Attach `dist/summon_v*.rpm` to release.
- [ ] Attach `dist/summon_v*.deb` to release.
- [ ] Attach `dist/CHANGELOG.md` to release.
- [ ] Attach `dist/SHA256SUMS.txt` to the release.
- [ ] Attach `dist/goreleaser/summon-darwin-amd64.tar.gz` to release.
- [ ] Attach `dist/goreleaser/summon-linux-amd64.tar.gz` to release.
- [ ] Attach `dist/goreleaser/summon-windows-amd64.tar.gz` to release.
- [ ] Attach `dist/goreleaser/summon_v*.rpm` to release.
- [ ] Attach `dist/goreleaser/summon_v*.deb` to release.
- [ ] Attach `dist/goreleaser/CHANGELOG.md` to release.
- [ ] Attach `dist/goreleaser/SHA256SUMS.txt` to the release.
- [ ] Publish the release as a "pre-released".

- [ ] Update homebrew tools
- [ ] In [`cyberark/homebrew-tools`](https://github.com/cyberark/homebrew-tools) repo, update
the [`summon.rb` formula](https://github.com/cyberark/homebrew-tools/blob/master/summon.rb#L4-L6) with a PR
using the file `dist/summon.rb`.
using the file `dist/goreleaser/summon.rb`.

- [ ] Publish the release as a regular release.

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.acceptance
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN bundle install
# Build summon
WORKDIR /summon
COPY . .
RUN go build -o /bin/summon cmd/main.go
COPY ./dist/goreleaser/summon-linux_linux_amd64/summon /bin/summon

# Run tests
WORKDIR /summon/acceptance
Expand Down
36 changes: 29 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ pipeline {
steps { sh './bin/parse-changelog' }
}

stage('Build Go package') {
steps {
sh './build --skip-validate'
archiveArtifacts artifacts: "dist/*.tar.gz,dist/*.zip,dist/*.rb,dist/*.deb,dist/*.rpm,dist/*.txt", fingerprint: true
}
}

stage('Run unit tests') {
steps {
sh './test_unit'
Expand All @@ -45,6 +38,35 @@ pipeline {
}
}

stage('Build Release Artifacts') {
when {
not {
tag "v*"
}
}

steps {
sh './build --snapshot'
archiveArtifacts 'dist/goreleaser/'
}
}

stage('Build Release Artifacts and Create Pre Release') {
// Only run this stage when triggered by a tag
when { tag "v*" }

steps {
dir('./pristine-checkout') {
// Go releaser requires a pristine checkout
checkout scm

// Create draft release
sh "summon --yaml 'GITHUB_TOKEN: !var github/users/conjur-jenkins/api-token' ./build"
archiveArtifacts 'dist/goreleaser/'
}
}
}

stage('Run acceptance tests') {
steps {
sh './test_acceptance'
Expand Down
22 changes: 15 additions & 7 deletions build
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#!/bin/bash -e

git fetch --tags # jenkins does not do this automatically yet
CURRENT_DIR=$(pwd)

echo "Current dir: $CURRENT_DIR"

MOUNT_DIR="/summon"

GORELEASER_IMAGE="goreleaser/goreleaser:latest-cgo"
GORELEASER_IMAGE="goreleaser/goreleaser:latest"

git fetch --tags # jenkins does not do this automatically yet

docker pull "$GORELEASER_IMAGE"
docker pull "${GORELEASER_IMAGE}"
docker run --rm -t \
--env GITHUB_TOKEN \
-v "$CURRENT_DIR:$MOUNT_DIR" \
-w "$MOUNT_DIR" \
"${GORELEASER_IMAGE}" --rm-dist "$@"

docker run --rm \
-v "$PWD:/summon" \
-w /summon \
"$GORELEASER_IMAGE" release --rm-dist "$@"
echo "Releases built. Archives can be found in dist/goreleaser"

0 comments on commit a96dc6d

Please sign in to comment.