Skip to content

Commit 60d0609

Browse files
Merge pull request #151 from digitalocean/varsha/new-release-workflow
Update release workflow
2 parents 40b8be2 + 7b44dec commit 60d0609

File tree

5 files changed

+77
-29
lines changed

5 files changed

+77
-29
lines changed

.github/build

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,40 @@
1+
name: release
12
on:
2-
release:
3-
types: [published, edited, prereleased]
4-
name: publish-release
3+
workflow_dispatch:
4+
# Inputs the workflow accepts.
5+
inputs:
6+
tag:
7+
# Friendly description to be shown in the UI instead of 'name'
8+
description: 'tag and release to create'
9+
# Input has to be provided for the workflow to run
10+
required: true
11+
env:
12+
GITHUB_ENV: ".env"
513
jobs:
6-
generate:
7-
name: Create release-artifacts
14+
release:
815
runs-on: ubuntu-latest
916
steps:
10-
- name: Checkout the repository
11-
uses: actions/checkout@master
12-
- name: Generate artifacts
13-
uses: skx/github-action-build@master
14-
- name: Upload artifacts
15-
uses: skx/github-action-publish-binaries@master
17+
- name: Install go
18+
uses: actions/setup-go@0caeaed6fd66a828038c2da3c0f662a42862658f
19+
with:
20+
go-version: ^1.17
21+
- name: Check out code into the Go module directory
22+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
23+
- name: Login to dockerhub to push the image
24+
run: echo "${{ secrets.DockerHubToken }}" | docker login --username ${DOCKER_USER} --password-stdin
25+
env:
26+
DOCKER_USER: ${{ secrets.DockerHubUser }}
27+
- name: run make release ${{ github.event.inputs.tag }}
28+
run: make docker-build docker-push build-binaries
29+
env:
30+
TAG: ${{ github.event.inputs.tag }}
31+
- name: Create Release
32+
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
1633
env:
1734
GITHUB_TOKEN: ${{ secrets.TOKEN }}
1835
with:
19-
args: 'clusterlint-*'
36+
# uses the HEAD on the default branch when creating the tag
37+
tag_name: ${{ github.event.inputs.tag }}
38+
release_name: Release ${{ github.event.inputs.tag }}
39+
files: |
40+
clusterlint-*

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the clusterlint binary
2-
FROM golang:1.16 as builder
2+
FROM golang:1.17 as builder
33
WORKDIR /workspace
44
# Copy the Go Modules manifests
55
COPY go.mod go.mod

Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Image URL to use all building/pushing image targets
2+
IMG ?= digitalocean/clusterlint
3+
TAG ?= dev
4+
5+
# Build the docker image
6+
docker-build:
7+
docker build . -t ${IMG}:${TAG}
8+
9+
# Push the docker image
10+
docker-push:
11+
docker push ${IMG}:${TAG}
12+
13+
# Build all binaries and sha sums for release
14+
build-binaries:
15+
GOOS=linux GOARCH=amd64 go build -mod=vendor -o clusterlint ./cmd/clusterlint; tar -czvf clusterlint-${TAG}-linux-amd64.tar.gz ./clusterlint
16+
GOOS=linux GOARCH=386 go build -mod=vendor -o clusterlint ./cmd/clusterlint; tar -czvf clusterlint-${TAG}-linux-386.tar.gz ./clusterlint
17+
GOOS=darwin GOARCH=amd64 go build -mod=vendor -o clusterlint ./cmd/clusterlint; tar -czvf clusterlint-${TAG}-darwin-amd64.tar.gz ./clusterlint
18+
GOOS=darwin GOARCH=arm64 go build -mod=vendor -o clusterlint ./cmd/clusterlint; tar -czvf clusterlint-${TAG}-darwin-arm64.tar.gz ./clusterlint
19+
GOOS=windows GOARCH=amd64 go build -mod=vendor -o clusterlint.exe ./cmd/clusterlint; tar -czvf clusterlint-${TAG}-windows-amd64.tar.gz ./clusterlint
20+
GOOS=windows GOARCH=386 go build -mod=vendor -o clusterlint.exe ./cmd/clusterlint; tar -czvf clusterlint-${TAG}-windows-386.tar.gz ./clusterlint
21+
sha256sum clusterlint-${TAG}-linux-amd64.tar.gz >> clusterlint-${TAG}-checksums.sha256
22+
sha256sum clusterlint-${TAG}-linux-386.tar.gz >> clusterlint-${TAG}-checksums.sha256
23+
sha256sum clusterlint-${TAG}-darwin-amd64.tar.gz >> clusterlint-${TAG}-checksums.sha256
24+
sha256sum clusterlint-${TAG}-darwin-arm64.tar.gz >> clusterlint-${TAG}-checksums.sha256
25+
sha256sum clusterlint-${TAG}-windows-amd64.tar.gz >> clusterlint-${TAG}-checksums.sha256
26+
sha256sum clusterlint-${TAG}-windows-386.tar.gz >> clusterlint-${TAG}-checksums.sha256
27+
28+
29+

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ $ clusterlint --plugins=/path/to/plugin.so list
123123
$ clusterlint --plugins=/path/to/plugin.so run -c my-plugin-check
124124
```
125125

126+
## Release
127+
128+
To release a new version of clusterlint, go to the actions page on GitHub, click on `Run workflow`.
129+
Specify the new tag to create. Make sure the tag is prefixed with `v`.
130+
131+
The workflow does the following:
132+
133+
- Checks out the source code from the default branch
134+
- Login with dockerhub credentials specified as secrets
135+
- Builds the docker image digitalocean/clusterlint:<tag>
136+
- Pushes digitalocean/clusterlint:<tag> to dockerhub
137+
- Builds binaries for all archs and computes sha256 sums for each binary
138+
- Creates release and tags the latest commit on the default branch with the input tag specified when workflow is triggered
139+
126140
## Contributing
127141

128142
Contributions are welcome, in the form of either issues or pull requests. Please

0 commit comments

Comments
 (0)