Skip to content

Commit

Permalink
chore: merge private to public [v8] (#288)
Browse files Browse the repository at this point in the history
Pulls in `release-please` configuration.
  • Loading branch information
cwaldren-ld authored Feb 7, 2024
1 parent 21866d0 commit a7f369b
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 13 deletions.
34 changes: 34 additions & 0 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish Artifacts
description: 'Publish artifacts to Github Release'
inputs:
token:
description: 'Token to use for publishing.'
required: true
dry-run:
description: 'Is this a dry run. If so no package will be published.'
required: false
default: 'true'
tag:
description: 'Tag to upload artifacts to.'
required: true

runs:
using: composite
steps:
- name: Git clean
shell: bash
run: git clean -f
- name: Run Goreleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean ${{ inputs.dry-run == 'true' && '--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/*.deb ./dist/*.rpm ./dist/*.tar.gz ./dist/*.txt --clobber
19 changes: 8 additions & 11 deletions .github/actions/unit-tests/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Unit Tests
description: "Runs Relay's unit tests + linters and optionally gathers coverage."
inputs:
go-version:
description: 'Go version to use for build & test.'
required: true
lint:
description: 'Whether to run linters.'
required: false
Expand All @@ -16,11 +13,11 @@ inputs:
runs:
using: composite
steps:
- name: Setup Go ${{ inputs.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ inputs.go-version }}

- name: Get Go version
id: go-version
shell: bash
run: |
echo "version=$(go version | awk '{print $3}')" >> $GITHUB_OUTPUT
- name: Lint
if: inputs.lint == 'true'
shell: bash
Expand All @@ -36,7 +33,7 @@ runs:
if: steps.test.outcome == 'success'
id: process-test
shell: bash
run: go-junit-reporter < raw_report.txt > junit_report.xml
run: go run github.com/jstemmer/go-junit-[email protected] < raw_report.txt > junit_report.xml

- name: Test with coverage
if: inputs.coverage == 'true'
Expand All @@ -48,12 +45,12 @@ runs:
if: steps.process-test.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: Test-result-go${{ inputs.go-version }}
name: Test-result-${{ steps.go-version.outputs.version }}
path: junit_report.xml

- name: Upload coverage results
if: steps.test-coverage.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: Coverage-result-go${{ inputs.go-version }}
name: Coverage-result-${{ steps.go-version.outputs.version }}
path: build/coverage*
5 changes: 4 additions & 1 deletion .github/workflows/common_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ jobs:
- 8000:8000
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/unit-tests
- name: Setup Go ${{ inputs.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ inputs.go-version }}
- uses: ./.github/actions/unit-tests
with:
lint: 'true'
coverage: 'true'

Expand Down
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
45 changes: 45 additions & 0 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish Images and Artifacts
on:
workflow_dispatch:
inputs:
dry_run:
description: 'Skip publishing to DockerHub'
type: boolean
required: false
default: true
tag:
description: 'Tag to upload binary artifacts to.'
type: string
required: true

jobs:
go-versions:
uses: ./.github/workflows/go-versions.yml

build-publish:
needs: go-versions
runs-on: ubuntu-latest
permissions:
id-token: write # Needed to get Docker tokens during publishing.
contents: write # Needed to upload release artifacts
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go ${{ needs.go-versions.outputs.latest }}
uses: actions/setup-go@v4
with:
go-version: ${{ needs.go-versions.outputs.latest }}
- name: Build and Test
uses: ./.github/actions/unit-tests
- name: 'Get Docker token'
uses: launchdarkly/gh-actions/actions/[email protected]
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
ssm_parameter_pairs: '/global/services/docker/public/username = DOCKER_USERNAME, /global/services/docker/public/token = DOCKER_TOKEN'
- name: Publish Package
uses: ./.github/actions/publish
with:
token: ${{ secrets.GITHUB_TOKEN }}
dry-run: ${{ inputs.dry_run }}
tag: ${{ inputs.tag }}
53 changes: 53 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Run Release Please

on:
push:
branches:
- v8

jobs:
go-versions:
uses: ./.github/workflows/go-versions.yml

release-please:
runs-on: ubuntu-latest
outputs:
released_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:
token: ${{secrets.GITHUB_TOKEN}}

release-relay:
permissions:
id-token: write # Needed to obtain Docker tokens
contents: write # Needed to upload release artifacts

needs: [ release-please, go-versions ]
if: ${{ needs.release-please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: launchdarkly/gh-actions/actions/[email protected]
name: 'Get Docker token'
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
ssm_parameter_pairs: '/global/services/docker/public/username = DOCKER_USERNAME, /global/services/docker/public/token = DOCKER_TOKEN'

- name: Setup Go ${{ needs.go-versions.outputs.latest }}
uses: actions/setup-go@v4
with:
go-version: ${{ needs.go-versions.outputs.latest }}

- uses: ./.github/actions/unit-tests

- uses: ./.github/actions/publish
with:
dry-run: 'false'
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.release-please.outputs.tag_name }}
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"." : "8.2.3"
}
2 changes: 1 addition & 1 deletion relay/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
package version

// Version is the package version
const Version = "8.2.3"
const Version = "8.2.3" // {{ x-release-please-version }}
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,
"versioning": "default",
"bootstrap-sha": "21866d02812c93457097540ee49f098bc405fdec",
"include-component-in-tag" : false,
"extra-files": [
"relay/version/version.go"
]
}
}
}

0 comments on commit a7f369b

Please sign in to comment.