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

chore: add release-please and Github Actions for CI [v2] #187

Merged
merged 6 commits into from
Feb 21, 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
18 changes: 0 additions & 18 deletions .circleci/config.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI Workflow
description: 'Shared CI workflow.'
inputs:
run_linter:
description: 'If true, run linter, otherwise only run unit tests.'
required: false
default: 'true'

runs:
using: composite
steps:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.18
- name: Run tests
shell: bash
run: make test
- name: Run linter
if: ${{ inputs.run_linter == 'true' }}
shell: bash
run: make lint
27 changes: 27 additions & 0 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish Artifacts
description: 'Publish artifacts to Github Release'
inputs:
token:
description: 'Token to use for publishing.'
required: true
tag:
description: 'Tag to upload artifacts to.'
required: true

runs:
using: composite
steps:
- name: Run Goreleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean --skip=publish
env:
GITHUB_TOKEN: ${{ inputs.token }}

- name: Upload Release Artifacts
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.token }}
run: |
gh release upload ${{ inputs.tag }} ./dist/*.tar.gz ./dist/*.zip --clobber
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Run CI
on:
push:
branches: [ 'v2' ]
paths-ignore:
- '**.md' # Do not need to run CI for markdown changes.
pull_request:
branches: [ 'v2', 'feat/**' ]
paths-ignore:
- '**.md'

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/ci
12 changes: 12 additions & 0 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Lint PR title

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
lint-pr-title:
uses: launchdarkly/gh-actions/.github/workflows/lint-pr-title.yml@main
15 changes: 15 additions & 0 deletions .github/workflows/manual-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Publish Artifacts
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to upload artifacts to.'
required: true
type: string

jobs:
manual-release:
uses: ./.github/workflows/release.yml
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ inputs.tag }}
30 changes: 30 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run Release Please

on:
push:
branches:
- v2

jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: google-github-actions/release-please-action@v4
id: release
with:
release-type: simple
token: ${{ secrets.GITHUB_TOKEN }}
target-branch: v2

release-sdk-test-harness:
permissions:
contents: write
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
uses: ./.github/workflows/release.yml
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.release-please.outputs.tag_name }}
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
workflow_call:
inputs:
token:
required: true
type: string
tag:
required: true
type: string

jobs:
release-sdk-test-harness:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/ci
with:
run_linter: 'false'
- uses: ./.github/actions/publish
with:
token: ${{ github.event.inputs.token }}
tag: ${{ github.event.inputs.tag }}
16 changes: 6 additions & 10 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ builds:
- CGO_ENABLED=0
main: .
binary: sdk-test-harness
ldflags:
- -s -w -X internal.version.Version={{.Version}}

goos:
- darwin
- linux
Expand Down Expand Up @@ -40,13 +37,12 @@ archives:
# For Linux & MacOS, we'll use the same OS and architecture strings that are returned by
# "uname -s" and "uname -m". So, for instance, the amd64 Linux build will be called
# "sdk-test-harness_Linux_x86_64.tar.gz".
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
name_template: >-
{{- .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}

files:
- LICENSE.txt
Expand Down
12 changes: 0 additions & 12 deletions .ldrelease/config.yml

This file was deleted.

6 changes: 0 additions & 6 deletions .ldrelease/publish-dry-run.sh

This file was deleted.

6 changes: 0 additions & 6 deletions .ldrelease/publish.sh

This file was deleted.

3 changes: 0 additions & 3 deletions .ldrelease/update-version.sh

This file was deleted.

3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"." : "2.8.1"
}
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import (
)

const defaultPort = 8111

//go:embed VERSION
var versionString string // comes from the VERSION file which we update for each release
const versionString string = "2.8.1" // {{ x-release-please-version }}

func main() {
fmt.Printf("sdk-test-harness v%s\n", strings.TrimSpace(versionString))
Expand Down
14 changes: 14 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"packages" : {
"." : {
"release-type" : "go",
"bump-minor-pre-major" : true,
"boostrap-sha" : "12774d23187e79d802083368132ea95b64a45cca",
"versioning" : "default",
"include-component-in-tag" : false,
"extra-files" : [
"main.go"
]
}
}
}
Loading