diff --git a/.github/actions/publish/action.yml b/.github/actions/publish/action.yml new file mode 100644 index 00000000..5e33b3c7 --- /dev/null +++ b/.github/actions/publish/action.yml @@ -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 diff --git a/.github/actions/unit-tests/action.yml b/.github/actions/unit-tests/action.yml index 90ca07c4..7ba8a4e2 100644 --- a/.github/actions/unit-tests/action.yml +++ b/.github/actions/unit-tests/action.yml @@ -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 @@ -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 @@ -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-report@v0.9.1 < raw_report.txt > junit_report.xml - name: Test with coverage if: inputs.coverage == 'true' @@ -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* diff --git a/.github/workflows/common_ci.yml b/.github/workflows/common_ci.yml index a24c3fe5..af3a3b40 100644 --- a/.github/workflows/common_ci.yml +++ b/.github/workflows/common_ci.yml @@ -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' diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml new file mode 100644 index 00000000..4ba79c13 --- /dev/null +++ b/.github/workflows/lint-pr-title.yml @@ -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 diff --git a/.github/workflows/manual-publish.yml b/.github/workflows/manual-publish.yml new file mode 100644 index 00000000..88111b7a --- /dev/null +++ b/.github/workflows/manual-publish.yml @@ -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/release-secrets@release-secrets-v1.0.1 + 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 }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 00000000..04c1f8f5 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -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/release-secrets@release-secrets-v1.0.1 + 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 }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..6e51a6e5 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + "." : "8.2.3" +} diff --git a/relay/version/version.go b/relay/version/version.go index 5fdc06cb..00d7c873 100644 --- a/relay/version/version.go +++ b/relay/version/version.go @@ -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 }} diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..ef6e6a12 --- /dev/null +++ b/release-please-config.json @@ -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" + ] + } + } +}