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
2 changes: 2 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright 2022 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause
name: golangci-lint

on:
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2022 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause
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

# Releases
dist/
26 changes: 26 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2022 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause
# Make sure to check the documentation at https://goreleaser.com
builds:
- env:
- CGO_ENABLED=0
ldflags:
- -X github.com/vmware-tanzu/asset-relocation-tool-for-kubernetes/cmd.Version={{ .Version }}
binary: relok8s
archives:
- replacements:
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:'
10 changes: 10 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,13 @@ To run all tests, including `test-external` do:
```bash
make test-all
```

### Releasing

Releases are cut manually like this:

```bash
VERSION=X.Y.Z && git tag "v${VERSION}" && git push origin "v${VERSION}"
```

The `X.Y.Z` version must be a semver compliant version string. Once the tag is pushed, a GitHub Action will produce the corresponding release using goreleaser.
105 changes: 0 additions & 105 deletions ci/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,6 @@ resources:
username: ((harbor-public.username))
password: ((harbor-public.token))

- name: release
type: github-release
icon: github
source:
owner: vmware-tanzu
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 @@ -142,95 +123,10 @@ jobs:
REGISTRY_USERNAME: ((harbor-private.username))
REGISTRY_PASSWORD: ((harbor-private.token))

- name: build
serial_groups: [version]
plan:
- in_parallel:
- get: test-image
passed:
- test
- get: source
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
inputs: [build, source, version]
params:
name: version/version
tag: version/version
commitish: source/.git/ref
globs:
- build/*
- do:
- task: make-args-file
image: test-image
config:
platform: linux
inputs:
- name: version
outputs:
- name: args-file
run:
path: bash
args:
- -exc
- |
echo "VERSION=$(cat version/version)" > args-file/args.env
- task: build-image
privileged: true
config:
platform: linux
image_resource:
type: registry-image
source:
repository: harbor-repo.vmware.com/dockerhub-proxy-cache/concourse/oci-build-task
username: ((harbor.username))
password: ((harbor.token))
inputs:
- name: args-file
- name: source
path: .
outputs:
- name: image
params:
BUILD_ARGS_FILE: args-file/args.env
REGISTRY_MIRRORS: mirror.kokoni.info
run:
path: build
- 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:
- in_parallel:
- get: docker-image
passed:
- build
trigger: true
- get: nginx-chart
- task: relocate
Expand Down Expand Up @@ -283,7 +179,6 @@ jobs:
<(tar xzfO nginx-chart/*.tgz nginx/values.yaml) \
<(tar xzfO rewritten-chart/chart.tgz nginx/values.yaml)


- name: test-pull-request
serial: true
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.