Skip to content

Commit

Permalink
Merge pull request #126 from vultr/CLOUD-2086
Browse files Browse the repository at this point in the history
update/add goreleaser
  • Loading branch information
happytreees committed Sep 30, 2022
2 parents 799b344 + 5781c61 commit e6ecab8
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 71 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/releaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: "Automatic Releaser"

on:
push:
branches:
- master

permissions:
contents: write

jobs:
check-commit:
runs-on: ubuntu-latest
outputs:
msg_check: ${{ steps.check-msg.outputs.match }}
steps:
- name: Check Message
id: check-msg
run: |
pattern="^Release v[0-9]+.[0-9]+.[0-9]+ #(minor|major|patch)$"
if [[ "${{ github.event.head_commit.message }}" =~ ${pattern} ]]; then
echo ::set-output name=match::true
fi
create-tag:
runs-on: ubuntu-latest
if: needs.check-commit.outputs.msg_check == 'true'
needs: check-commit
outputs:
new_tag: ${{ steps.tagger.outputs.new_tag }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'

- name: Bump version and push tag
id: tagger
uses: anothrNick/github-tag-action@1.36.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: "none"

goreleaser:
runs-on: ubuntu-latest
needs: create-tag
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
-
name: Docker Login
env:
DOCKER_USERNAME: ${{ github.repository_owner }}
DOCKER_PASSWORD: ${{ secrets.CR_PAT }}
run: |
echo "${DOCKER_PASSWORD}" | docker login ghcr.io --username "${DOCKER_USERNAME}" --password-stdin
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.CR_PAT }}
-
name: Clear
if: always()
run: |
rm -f ${HOME}/.docker/config.json
release:
runs-on: ubuntu-latest
needs: ["goreleaser", "create-tag"]
name: Release Notification
steps:
- run: |
echo "{\"text\":\"vultr-cloud-controller-manager : Release https://github.com/${{ github.repository }}/releases/tag/${{ needs.create-tag.outputs.new_tag }} \"}" > mattermost.json
- uses: mattermost/action-mattermost-notify@master
env:
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
MATTERMOST_USERNAME: ${{ secrets.MATTERMOST_USERNAME}}
MATTERMOST_ICON: ${{ secrets.MATTERMOST_ICON }}
57 changes: 0 additions & 57 deletions .github/workflows/tagged-releases.yml

This file was deleted.

35 changes: 21 additions & 14 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
env:
- CGO_ENABLED=0
before:
hooks:
- go test ./...
- go mod download
- go generate ./...

builds:
-
main: ./main.go

binary: vultr-cloud-controller-manager

env:
- CGO_ENABLED=0

mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath #removes all file system paths from the compiled executable
- -ldflags
- '-s -w'
goos:
- linux
goarch:
- amd64
- '386'
- arm
- arm64
binary: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}'

archives:
- format: zip
-
format: zip
files:
- none*
name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}'
Expand All @@ -30,10 +33,14 @@ checksum:
name_template: '{{ .ProjectName }}_v{{ .Version }}_SHA256SUMS'
algorithm: sha256

dockers:
- dockerfile: Dockerfile.goreleaser
image_templates:
- "ghcr.io/vultr/vultr-cloud-controller-manager/vultr-cloud-controller-manager:release"
- "ghcr.io/vultr/vultr-cloud-controller-manager/vultr-cloud-controller-manager:{{ .Tag }}"

release:
draft: true
extra_files:
- glob: "./docs/releases/latest.yml"
draft: false

changelog:
skip: true
skip: false

0 comments on commit e6ecab8

Please sign in to comment.