Skip to content

Commit 2812b45

Browse files
Merge pull request #128 from adamkpickering/simplify-repo-tooling
Simplify `charts-build-scripts` tooling
2 parents d6e03e5 + 05baea9 commit 2812b45

21 files changed

+133
-363
lines changed

.dockerignore

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

.github/workflows/label-all-new-issues.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
1-
name: Pull-Request
1+
name: Lint and Test Build
22

33
on:
44
pull_request:
55

66
jobs:
7-
build:
7+
test:
88
runs-on: ubuntu-latest
9-
container:
10-
image: rancher/dapper:v0.5.4
119
steps:
12-
- uses: actions/checkout@v1
13-
- name: Run CI
14-
run: dapper ci
10+
- uses: actions/checkout@v4
11+
12+
- uses: actions/setup-go@v4
13+
with:
14+
go-version: '1.22'
1515

16-
build-validate:
16+
- name: Run unit tests
17+
run: go test ./...
18+
19+
lint:
1720
runs-on: ubuntu-latest
1821
steps:
19-
- name: Checkout
20-
uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
23+
24+
- uses: golangci/golangci-lint-action@v4
25+
with:
26+
version: v1.57
2127

22-
- name: Build binaries
23-
env:
24-
CROSS: false
25-
run: make build
28+
build:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
2632

27-
- name: Checkout charts Repo
28-
uses: actions/checkout@v3
33+
- uses: actions/setup-go@v4
2934
with:
30-
repository: rancher/charts
31-
path: charts
35+
go-version: '1.22'
3236

33-
- name: Run Validation
34-
run: |
35-
cd charts
36-
../bin/charts-build-scripts validate
37+
- name: Run goreleaser
38+
uses: goreleaser/goreleaser-action@v5
39+
with:
40+
args: build --snapshot

.github/workflows/release.yaml

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,28 @@
1+
name: Make a Release
2+
13
on:
2-
release:
3-
types: [created]
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
410

511
jobs:
6-
build-assets:
12+
goreleaser:
713
runs-on: ubuntu-latest
814
steps:
9-
- uses: actions/checkout@v2
10-
- name: Build binaries
11-
env:
12-
CROSS: true
13-
run: make build
14-
- name: Get release
15-
id: get_release
16-
uses: bruceadams/[email protected]
17-
env:
18-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19-
- uses: actions/upload-release-asset@v1
20-
env:
21-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
- uses: actions/checkout@v4
2216
with:
23-
upload_url: ${{ steps.get_release.outputs.upload_url }}
24-
asset_path: bin/charts-build-scripts
25-
asset_name: charts-build-scripts
26-
asset_content_type: application/octet-stream
27-
- uses: actions/upload-release-asset@v1
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
fetch-depth: 0
18+
19+
- uses: actions/setup-go@v4
3020
with:
31-
upload_url: ${{ steps.get_release.outputs.upload_url }}
32-
asset_path: bin/charts-build-scripts-darwin
33-
asset_name: charts-build-scripts-darwin
34-
asset_content_type: application/octet-stream
35-
- uses: actions/upload-release-asset@v1
21+
go-version: '1.22'
22+
23+
- name: Run goreleaser
24+
uses: goreleaser/goreleaser-action@v5
25+
with:
26+
args: release
3627
env:
3728
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
with:
39-
upload_url: ${{ steps.get_release.outputs.upload_url }}
40-
asset_path: bin/charts-build-scripts-windows
41-
asset_name: charts-build-scripts-windows
42-
asset_content_type: application/octet-stream
43-

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ charts-build-scripts
88
.DS_Store
99
pkg/.DS_Store
1010
templates/.DS_Store
11-
.vscode
11+
.vscode
12+
dist/

.goreleaser.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: 1
2+
3+
project_name: charts-build-scripts
4+
5+
before:
6+
hooks:
7+
- go mod tidy
8+
9+
builds:
10+
- env:
11+
- CGO_ENABLED=0
12+
goos:
13+
- linux
14+
- windows
15+
- darwin
16+
goarch:
17+
- amd64
18+
- arm
19+
- arm64
20+
ldflags:
21+
- -X main.Version={{.Version}} -X main.GitCommit={{.ShortCommit}}
22+
23+
archives:
24+
- format: binary
25+
name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}'
26+
27+
checksum:
28+
name_template: checksums.txt
29+
30+
changelog:
31+
sort: asc
32+
filters:
33+
exclude:
34+
- "^docs:"
35+
- "^test:"

Dockerfile.dapper

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

Makefile

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

README.md

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
charts-build-scripts
2-
========
1+
# charts-build-scripts
32

4-
## Build Scripts For Rancher Charts
3+
## How to Use `charts-build-scripts`
54

6-
## Before running the scripts
7-
8-
#### If you are creating a new charts repository
5+
### Charts Repository Setup
96

107
Checkout the Git branch that corresponds to your Staging or Live branch.
118

@@ -15,24 +12,67 @@ Export BRANCH_ROLE as `staging`, `live`, or `custom`. Then run:
1512
curl -s https://raw.githubusercontent.com/rancher/charts-build-scripts/master/init.sh > /dev/null | sh
1613
```
1714

18-
## Building
15+
### Building
1916

2017
`make`
2118

22-
## Running
19+
### Running
2320

2421
`./bin/charts-build-scripts`
2522

26-
## Validation command
23+
### Validation command
2724

2825
For more information on the validation command, please see [`docs/validate.md`](docs/validate.md).
2926

30-
## Debugging
27+
### Debugging
3128

3229
For more information on how to debug this project, please see [`docs/debugging.md`](docs/debugging.md).
3330

31+
32+
## Developing `charts-build-scripts`
33+
34+
### How to Run
35+
36+
```
37+
go run main.go
38+
```
39+
40+
### How to Run Unit Tests
41+
42+
```
43+
go test ./...
44+
```
45+
46+
### How to Lint
47+
48+
```
49+
golangci-lint run ./...
50+
```
51+
52+
### How to Release
53+
54+
Releases are done via a github action that uses [`goreleaser`](https://goreleaser.com/).
55+
In order to release, simply tag the commit that you want the release
56+
to be based off of with a tag that is in semver format. For example:
57+
```
58+
git tag v0.1.9
59+
```
60+
Then, push that tag to the the rancher/charts-build-scripts repo.
61+
Here is an example, assuming that rancher/charts-build-scripts is
62+
configured as `upstream` in your local repo:
63+
```
64+
git push upstream --tags
65+
```
66+
Pushing the tag will trigger a github actions workflow that will use
67+
the `goreleaser` action to build binaries for many different combinations
68+
of OS and processor architecture. This same `goreleaser` action will
69+
then create a release using these binaries. Release notes will be
70+
constructed from commit messages.
71+
72+
3473
## License
35-
Copyright (c) 2019 [Rancher Labs, Inc.](http://rancher.com)
74+
75+
Copyright (c) 2024 [Rancher Labs, Inc.](http://rancher.com)
3676

3777
Licensed under the Apache License, Version 2.0 (the "License");
3878
you may not use this file except in compliance with the License.

scripts/boilerplate.go.txt

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

0 commit comments

Comments
 (0)