Skip to content

Commit

Permalink
Merge pull request #151 from digitalocean/varsha/new-release-workflow
Browse files Browse the repository at this point in the history
Update release workflow
  • Loading branch information
varshavaradarajan committed Aug 16, 2022
2 parents 40b8be2 + 7b44dec commit 60d0609
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 29 deletions.
16 changes: 0 additions & 16 deletions .github/build

This file was deleted.

45 changes: 33 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
name: release
on:
release:
types: [published, edited, prereleased]
name: publish-release
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
tag:
# Friendly description to be shown in the UI instead of 'name'
description: 'tag and release to create'
# Input has to be provided for the workflow to run
required: true
env:
GITHUB_ENV: ".env"
jobs:
generate:
name: Create release-artifacts
release:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@master
- name: Generate artifacts
uses: skx/github-action-build@master
- name: Upload artifacts
uses: skx/github-action-publish-binaries@master
- name: Install go
uses: actions/setup-go@0caeaed6fd66a828038c2da3c0f662a42862658f
with:
go-version: ^1.17
- name: Check out code into the Go module directory
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Login to dockerhub to push the image
run: echo "${{ secrets.DockerHubToken }}" | docker login --username ${DOCKER_USER} --password-stdin
env:
DOCKER_USER: ${{ secrets.DockerHubUser }}
- name: run make release ${{ github.event.inputs.tag }}
run: make docker-build docker-push build-binaries
env:
TAG: ${{ github.event.inputs.tag }}
- name: Create Release
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
args: 'clusterlint-*'
# uses the HEAD on the default branch when creating the tag
tag_name: ${{ github.event.inputs.tag }}
release_name: Release ${{ github.event.inputs.tag }}
files: |
clusterlint-*
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the clusterlint binary
FROM golang:1.16 as builder
FROM golang:1.17 as builder
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
Expand Down
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Image URL to use all building/pushing image targets
IMG ?= digitalocean/clusterlint
TAG ?= dev

# Build the docker image
docker-build:
docker build . -t ${IMG}:${TAG}

# Push the docker image
docker-push:
docker push ${IMG}:${TAG}

# Build all binaries and sha sums for release
build-binaries:
GOOS=linux GOARCH=amd64 go build -mod=vendor -o clusterlint ./cmd/clusterlint; tar -czvf clusterlint-${TAG}-linux-amd64.tar.gz ./clusterlint
GOOS=linux GOARCH=386 go build -mod=vendor -o clusterlint ./cmd/clusterlint; tar -czvf clusterlint-${TAG}-linux-386.tar.gz ./clusterlint
GOOS=darwin GOARCH=amd64 go build -mod=vendor -o clusterlint ./cmd/clusterlint; tar -czvf clusterlint-${TAG}-darwin-amd64.tar.gz ./clusterlint
GOOS=darwin GOARCH=arm64 go build -mod=vendor -o clusterlint ./cmd/clusterlint; tar -czvf clusterlint-${TAG}-darwin-arm64.tar.gz ./clusterlint
GOOS=windows GOARCH=amd64 go build -mod=vendor -o clusterlint.exe ./cmd/clusterlint; tar -czvf clusterlint-${TAG}-windows-amd64.tar.gz ./clusterlint
GOOS=windows GOARCH=386 go build -mod=vendor -o clusterlint.exe ./cmd/clusterlint; tar -czvf clusterlint-${TAG}-windows-386.tar.gz ./clusterlint
sha256sum clusterlint-${TAG}-linux-amd64.tar.gz >> clusterlint-${TAG}-checksums.sha256
sha256sum clusterlint-${TAG}-linux-386.tar.gz >> clusterlint-${TAG}-checksums.sha256
sha256sum clusterlint-${TAG}-darwin-amd64.tar.gz >> clusterlint-${TAG}-checksums.sha256
sha256sum clusterlint-${TAG}-darwin-arm64.tar.gz >> clusterlint-${TAG}-checksums.sha256
sha256sum clusterlint-${TAG}-windows-amd64.tar.gz >> clusterlint-${TAG}-checksums.sha256
sha256sum clusterlint-${TAG}-windows-386.tar.gz >> clusterlint-${TAG}-checksums.sha256



14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ $ clusterlint --plugins=/path/to/plugin.so list
$ clusterlint --plugins=/path/to/plugin.so run -c my-plugin-check
```

## Release

To release a new version of clusterlint, go to the actions page on GitHub, click on `Run workflow`.
Specify the new tag to create. Make sure the tag is prefixed with `v`.

The workflow does the following:

- Checks out the source code from the default branch
- Login with dockerhub credentials specified as secrets
- Builds the docker image digitalocean/clusterlint:<tag>
- Pushes digitalocean/clusterlint:<tag> to dockerhub
- Builds binaries for all archs and computes sha256 sums for each binary
- Creates release and tags the latest commit on the default branch with the input tag specified when workflow is triggered

## Contributing

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

0 comments on commit 60d0609

Please sign in to comment.