Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate draft release creation with Goreleaser #210

Merged
merged 1 commit into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/artefacts/artifacts

[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.
doodlesbykumbi marked this conversation as resolved.
Show resolved Hide resolved
- [ ] 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"