Skip to content

Commit

Permalink
chore: setup release process with github actions
Browse files Browse the repository at this point in the history
Signed-off-by: Yoriyasu Yano <[email protected]>
  • Loading branch information
yorinasub17 committed Nov 8, 2023
1 parent 7cf4299 commit 5b909b7
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: release

on:
push:
branches:
- main

jobs:
release:
name: release
runs-on: ubuntu-latest
permissions:
checks: write
contents: write
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0

- name: Release
run: |
npm install @semantic-release/exec
npx -y semantic-release@v22
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: release-notes
path: /tmp/release-notes.md

goreleaser:
name: upload binaries
runs-on: ubuntu-latest
needs: release
permissions:
id-token: write
checks: write
contents: write
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
fetch-depth: 0

- uses: sigstore/cosign-installer@1fc5bd396d372bee37d608f955b336615edf79c8 # v3.2.0

- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: "1.20"
cache: true

- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: release-notes
path: /tmp

- uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
with:
distribution: goreleaser
version: latest
# NOTE: we use parallelism 1 because the cosign process is not concurrency safe.
args: release --parallelism 1 --release-notes /tmp/release-notes.md --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COSIGN_EXPERIMENTAL: true
46 changes: 46 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
before:
hooks:
- go mod tidy

builds:
- main: .
binary: github-app-token
env:
- CGO_ENABLED=0
flags:
- -trimpath #removes all file system paths from the compiled executable
ldflags:
- "-s -w"
goos:
- linux
goarch:
- amd64

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

signs:
- id: github-app-token-keyless
artifacts: archive
signature: "${artifact}-keyless.sig"
certificate: "${artifact}-keyless.pem"
cmd: cosign
args: ["sign-blob", "-y", "--output-signature", "${artifact}-keyless.sig", "--output-certificate", "${artifact}-keyless.pem", "${artifact}"]
- id: checksum-keyless
artifacts: checksum
signature: "${artifact}-keyless.sig"
certificate: "${artifact}-keyless.pem"
cmd: cosign
args: ["sign-blob", "-y", "--output-signature", "${artifact}-keyless.sig", "--output-certificate", "${artifact}-keyless.pem", "${artifact}"]

checksum:
name_template: "{{ .ProjectName }}_checksums.txt"

snapshot:
name_template: "SNAPSHOT-{{ .ShortCommit }}"

release:
github:
owner: fensak-io
name: github-app-token
mode: keep-existing
20 changes: 20 additions & 0 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
branches: ["main"]
plugins:
- - "@semantic-release/commit-analyzer"
- preset: angular
releaseRules:
- type: chore
release: patch
# Override default rules for pre-1.0
- breaking: true
release: minor
- type: feat
release: patch
parserOpts:
noteKeywords:
- BREAKING CHANGE
- BREAKING CHANGES
- "@semantic-release/release-notes-generator"
- - "@semantic-release/exec"
- publishCmd: |
echo "${nextRelease.notes}" > /tmp/release-notes.md

0 comments on commit 5b909b7

Please sign in to comment.