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

Release new versions through GHA pipeline #450

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .github/workflows/docker-release.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/goreleaser.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write
packages: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Generate release notes
id: release-notes
uses: actions/github-script@v7
with:
result-encoding: string
script: |
return github.rest.repos.generateReleaseNotes({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "${{ github.ref_name }}",
}).then(response => response.data.body)
- name: Write release notes to file
run: |
cat << EOF > release-notes.md
${{ steps.release-notes.outputs.result }}
EOF
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean --release-notes release-notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 changes: 19 additions & 24 deletions .github/workflows/test-and-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,29 @@ name: Test

on:
push:
branches: '**'
pull_request:
branches: [ main ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod

- name: Test
run: |
git config user.email "[email protected]"
git config user.name "Talisman Maintainers"
go test -covermode=count -coverprofile=coverage.out -v ./...

- name: Codecov
# You may pin to the exact commit or the version.
# uses: codecov/codecov-action@e156083f13aff6830c92fc5faa23505779fbf649
uses: codecov/[email protected]

- name: Install bash_unit
run: bash <(curl -s https://raw.githubusercontent.com/pgrange/bash_unit/master/install.sh)

- name: Test install script
run: ./bash_unit test-install.sh
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Test
run: |
git config user.email "[email protected]"
git config user.name "Talisman Maintainers"
go test -covermode=count -coverprofile=coverage.out -v ./...
- name: Codecov
# You may pin to the exact commit or the version.
# uses: codecov/codecov-action@e156083f13aff6830c92fc5faa23505779fbf649
uses: codecov/[email protected]
- name: Install bash_unit
run: bash <(curl -s https://raw.githubusercontent.com/pgrange/bash_unit/master/install.sh)
- name: Test install script
run: ./bash_unit test-install.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ out/
# Go workspace file
go.work

release-notes.md
12 changes: 0 additions & 12 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ project_name: talisman

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
# - go generate ./...

builds:
- env:
Expand All @@ -21,29 +18,20 @@ builds:
- -s -w -X main.Version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}
main: ./cmd

# hooks:
# post:
# - ./compress-binary.sh "{{ .Path }}"


release:
draft: true
replace_existing_draft: true


archives:

- meta: false
format: binary
wrap_in_directory: true

name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"

checksum:
name_template: 'checksums'
algorithm: sha256


snapshot:
name_template: "{{ incpatch .Version }}-next"

Expand Down
17 changes: 0 additions & 17 deletions Dockerfile

This file was deleted.

20 changes: 0 additions & 20 deletions build

This file was deleted.

6 changes: 0 additions & 6 deletions build_binaries.bash

This file was deleted.

2 changes: 0 additions & 2 deletions clean

This file was deleted.

21 changes: 0 additions & 21 deletions compress-binary.sh

This file was deleted.

48 changes: 26 additions & 22 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,33 @@ If you are not sure how to begin contributing to Talisman, have a look at the is

## Developing locally

To contribute to Talisman, you need a working golang development
environment. Check [this link](https://golang.org/doc/install) to help
you get started with that.
To contribute to Talisman, you need a working golang development environment.
Check [this link](https://golang.org/doc/install) to help you get started.

Talisman now uses go modules (GO111MODULE=on) to manage dependencies

Once you have go 1.11 installed and setup, clone the talisman repository. In your
working copy, fetch the dependencies by having go mod fetch them for
you.
Once you have go installed and set up, clone the talisman repository. In your
working copy, fetch the dependencies by having go mod fetch them for you:

```
GO111MODULE=on go mod vendor
go mod vendor
```

To run tests `GO111MODULE=on go test -mod=vendor ./...`
Run the tests:

```
go test ./...
```

To build Talisman, we can use [gox](https://github.com/mitchellh/gox):
Build talisman:

```
gox -osarch="darwin/amd64 linux/386 linux/amd64"
go build -o dist/talisman -ldflags="-s -w" talisman/cmd
```

Convenience scripts `./build` and `./clean` perform build and clean-up as mentioned above.
To build for multiple platforms we use [GoReleaser](https://goreleaser.com/):

```
goreleaser build --snapshot --clean
```

## Submitting a Pull Request

Expand All @@ -42,20 +46,20 @@ To send in a pull request
4. Ensure that all the tests pass.
5. Submit the pull request.

## Updating Talisman Gihub Pages
## Updating Talisman GitHub Pages

1. Checkout a new branch from gh-pages
2. Navigate to the docs/ folder and update the files
3. See instructions for checking locally [here](https://github.com/thoughtworks/talisman/blob/gh-pages/README.md).
3. See instructions for checking locally [here](https://github.com/thoughtworks/talisman/blob/gh-pages/README.md).
4. Raise a pull request against the branch gh-pages

## Releasing

* Follow the instructions at the end of 'Developing locally' to build the binaries* Bump the [version in install.sh](https://github.com/thoughtworks/talisman/blob/d4b1b1d11137dbb173bf681a03f16183a9d82255/install.sh#L10) according to [semver](https://semver.org/) conventions
* Update the [expected hashes in install.sh](https://github.com/thoughtworks/talisman/blob/d4b1b1d11137dbb173bf681a03f16183a9d82255/install.sh#L16-L18) to match the new binaries you just created (`shasum -b -a256 ...`)
* Make release commit and tag with the new version prefixed by `v` (like `git tag v0.3.0`)
* Push your release commit and tag: `git push && git push --tags`
* [Create a new release in github](https://github.com/thoughtworks/talisman/releases/new), filling in the new commit tag you just created
* Update the install script hosted on github pages: `git checkout gh-pages`, `git checkout master -- install.sh`, `git commit -m ...`
1. Tag the commit to be released with the next version according to
[semver](https://semver.org/) conventions
2. Push the tag to trigger the GitHub Actions Release pipeline
3. Approve the [drafted GitHub Release](https://github.com/thoughtworks/talisman/releases)

The latest version will now be accessible to anyone who builds their own binaries, downloads binaries directly from github releases, or uses the install script from the website.
The latest version will now be accessible to anyone who builds their own
binaries, downloads binaries directly from GitHub Releases or homebrew, or uses
the install script from the website.
Loading