Skip to content

Commit

Permalink
ci: setup semantic release (#44)
Browse files Browse the repository at this point in the history
* ci: setup semantic release

Signed-off-by: David van der Spek <[email protected]>

* ci: remove setup node

Signed-off-by: David van der Spek <[email protected]>

---------

Signed-off-by: David van der Spek <[email protected]>
  • Loading branch information
davidspek authored Sep 29, 2023
1 parent 232ad1c commit 8ca27bc
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 40 deletions.
96 changes: 56 additions & 40 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,39 @@ env:
GOPATH: /home/runner/go/
GOPROXY: "https://proxy.golang.org"
jobs:
build:
name: Build
prepare:
name: Prepare release
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
outputs:
new_release_version: ${{ steps.semantic_release.outputs.new_release_version }}
new_release_published: ${{ steps.semantic_release.outputs.new_release_published }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- name: Checkout
uses: actions/checkout@v4
with:
go-version-file: go.mod
check-latest: true
- run: PATH=$PATH:$GOPATH/bin make build
image:
name: Build image
fetch-depth: 0
token: ${{ secrets.PLURAL_BOT_PAT }}
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
id: semantic_release
with:
dry_run: true
env:
GITHUB_TOKEN: ${{ secrets.PLURAL_BOT_PAT }}
NODE_AUTH_TOKEN: ${{ secrets.PLURAL_BOT_NPM_TOKEN }}
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true
- run: PATH=$PATH:$GOPATH/bin make docker-build
- run: PATH=$PATH:$GOPATH/bin make build
test:
name: Unit test
runs-on: ubuntu-latest
Expand All @@ -55,7 +68,9 @@ jobs:
publish:
name: Build and push Agent container
runs-on: ubuntu-20.04
needs: test
needs:
- prepare
- test
permissions:
contents: 'read'
id-token: 'write'
Expand All @@ -77,30 +92,11 @@ jobs:
type=sha
type=ref,event=pr
type=ref,event=branch
type=semver,pattern={{version}},value=${{ needs.prepare.outputs.new_release_version }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# - uses: google-github-actions/auth@v1
# with:
# workload_identity_provider: 'projects/${{ secrets.GOOGLE_PROJECT_ID }}/locations/global/workloadIdentityPools/github/providers/github'
# service_account: '[email protected]'
# token_format: 'access_token'
# create_credentials_file: true
# - uses: google-github-actions/[email protected]
# - name: Login to gcr
# run: gcloud auth configure-docker -q
# - name: installing plural
# id: plrl
# uses: pluralsh/[email protected]
# with:
# email: [email protected]
# - name: Login to plural registry
# uses: docker/login-action@v2
# with:
# registry: dkr.plural.sh
# username: [email protected]
# password: ${{ steps.plrl.outputs.token }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
Expand All @@ -115,16 +111,36 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
GIT_COMMIT=${{ github.sha }}
- name: slack webhook
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: workflow,job,repo,message,commit,author
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required
if: always()
release:
runs-on: ubuntu-latest
needs: build
permissions:
contents: 'read'
id-token: 'write'
if: github.event_name != 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PLURAL_BOT_PAT }}
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
id: semantic_release
if: github.event_name != 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.PLURAL_BOT_PAT }}
NODE_AUTH_TOKEN: ${{ secrets.PLURAL_BOT_NPM_TOKEN }}
- name: slack webhook
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: workflow,job,repo,message,commit,author
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required
if: always()
18 changes: 18 additions & 0 deletions .github/workflows/semantic-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Semantic PR"

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

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"branches": ["main"],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github"
]
}

0 comments on commit 8ca27bc

Please sign in to comment.