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

Add goreleaser #115

Merged
merged 14 commits into from
Jan 11, 2022
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: release

on:
push:
tags:
- "v*.*.*"

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.17.x
- name: Release
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ build/*
.idea
*.iml


Copy link
Contributor

Choose a reason for hiding this comment

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

add a comment indicating that this is a directory of releases

# Releases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

dist/
35 changes: 35 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not look right. Are we also building the binary in the hook? What for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can try to remove. It will probably work anyways.
Seems goreleaser builds the binaries itself, does not like to rely on makefiles or anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

- make clean
- env VERSION="{{ .Version }}" make build
builds:
- env:
- CGO_ENABLED=0
ldflags:
- -X github.com/vmware-tanzu/asset-relocation-tool-for-kubernetes/cmd.Version={{ .Version }}
goos:
josvazg marked this conversation as resolved.
Show resolved Hide resolved
- linux
- windows
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

- darwin
binary: relok8s
archives:
- replacements:
darwin: Darwin
Copy link
Contributor

Choose a reason for hiding this comment

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

this replacements to add capitalization does not feel right, in fact I do not like the filename resulting of it which uses underscore + Capitalized at the same time.

To me the only two replacements here should be the ones related to the arch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

linux: Linux
windows: Windows
386: i386
amd64: x86_64
name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}"
files:
- README.md
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
33 changes: 2 additions & 31 deletions ci/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,6 @@ resources:
repository: asset-relocation-tool-for-kubernetes
access_token: ((github.access_token))

- name: version
type: semver
icon: github
source:
driver: git
uri: git@github.com:vmware-tanzu/asset-relocation-tool-for-kubernetes.git
private_key: ((github.private_key))
branch: main
file: version
commit_message: "[ci skip] bump version to %version%"

- name: nginx-chart
type: helm-chart
icon: kubernetes
Expand Down Expand Up @@ -143,7 +132,7 @@ jobs:
REGISTRY_PASSWORD: ((harbor-private.token))

- name: build
serial_groups: [version]
serial_groups: []
plan:
- in_parallel:
- get: test-image
Expand All @@ -153,16 +142,13 @@ jobs:
trigger: true
passed:
- test
- get: version
params:
bump: patch
- in_parallel:
- do:
- task: build
image: test-image
file: source/ci/tasks/build.yaml
- put: release
josvazg marked this conversation as resolved.
Show resolved Hide resolved
inputs: [build, source, version]
inputs: [build, source]
params:
name: version/version
tag: version/version
Expand All @@ -174,8 +160,6 @@ jobs:
image: test-image
config:
platform: linux
inputs:
- name: version
outputs:
- name: args-file
run:
Expand Down Expand Up @@ -208,22 +192,9 @@ jobs:
- put: docker-image
inputs:
- image
- version
params:
image: image/image.tar
additional_tags: version/version
- put: version
params:
file: version/version
inputs: detect

- name: bump-minor-version
serial_groups: [version]
plan:
- put: version
inputs: detect
params:
bump: minor

- name: relocate-chart
plan:
Expand Down
2 changes: 0 additions & 2 deletions ci/tasks/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ platform: linux

inputs:
- name: source
- name: version

outputs:
- name: build
Expand All @@ -16,6 +15,5 @@ run:
args:
- -exc
- |
export VERSION=$(cat ../version/version)
make build-all
cp build/* ../build
1 change: 0 additions & 1 deletion version

This file was deleted.