Skip to content

Commit

Permalink
feat: automate pr labeling and releases (#59)
Browse files Browse the repository at this point in the history
- [x] update old release.yml to goreleaser.yml (fix some of its settings)
- [x] update privateer-sdk to latest (v0.1.0)

Signed-off-by: jmeridth <[email protected]>
  • Loading branch information
jmeridth authored Jan 3, 2025
1 parent 8b19d23 commit a0e47f4
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 70 deletions.
68 changes: 68 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
name-template: "v$RESOLVED_VERSION"
tag-template: "v$RESOLVED_VERSION"
template: |
# Changelog
$CHANGES
See details of [all code changes](https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION) since previous release
categories:
- title: "🚀 Features"
labels:
- "feature"
- "enhancement"
- title: "🐛 Bug Fixes"
labels:
- "fix"
- "bugfix"
- "bug"
- title: "🧰 Maintenance"
labels:
- "infrastructure"
- "automation"
- "documentation"
- "dependencies"
- "maintenance"
- "revert"
- title: "🏎 Performance"
label: "performance"
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
version-resolver:
major:
labels:
- "breaking"
minor:
labels:
- "enhancement"
- "fix"
patch:
labels:
- "documentation"
- "maintenance"
default: patch
autolabeler:
- label: "automation"
title:
- "/^(build|ci|perf|refactor|test).*/i"
- label: "enhancement"
title:
- "/^(style).*/i"
- label: "documentation"
title:
- "/^(docs).*/i"
- label: "feature"
title:
- "/^(feat).*/i"
- label: "fix"
title:
- "/^(fix).*/i"
- label: "infrastructure"
title:
- "/^(infrastructure).*/i"
- label: "maintenance"
title:
- "/^(chore|maintenance).*/i"
- label: "revert"
title:
- "/^(revert).*/i"
18 changes: 18 additions & 0 deletions .github/workflows/auto-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: "Auto Labeler"
on:
# pull_request_target event is required for autolabeler to support all PRs including forks
pull_request_target:
types: [opened, reopened, edited, synchronize]
permissions:
contents: read
jobs:
auto_labeler:
permissions:
contents: write
pull-requests: write
uses: jmeridth/reusable-workflows/.github/workflows/auto-labeler.yaml@53a9c808122ffaae9af948f72139fb4bd44ab74c
with:
config-name: release-drafter.yml
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: goreleaser

on:
push:
tags:
- "*"

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
## After having trouble with the PUBLISHER_TOKEN, I started down this path...
## But I never got the APP_ID to be accepted by the action
## Error: [@octokit/auth-app] appId option must be a number or numeric string
# - name: Generate token
# id: generate_token
# uses: tibdex/github-app-token@v1
# with:
# app_id: ${{ secrets.APP_ID }}
# private_key: ${{ secrets.APP_PEM }}
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23.4
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf
with:
distribution: goreleaser
version: ${{ github.ref_name }}
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
34 changes: 6 additions & 28 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,16 @@
## Reference: https://github.com/amannn/action-semantic-pull-request
---
name: "Lint PR Title"

on:
# pull_request_target event is required for autolabeler to support all PRs including forks
pull_request_target:
types: [opened, reopened, edited, synchronize]

permissions:
contents: read

jobs:
main:
lint_pr_title:
permissions:
contents: read
pull-requests: read
statuses: write
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Configure which types are allowed (newline-delimited).
# From: https://github.com/commitizen/conventional-commit-types/blob/master/index.json
# listing all below
types: |
build
chore
ci
docs
feat
fix
perf
refactor
revert
style
test
uses: jmeridth/reusable-workflows/.github/workflows/pr-title.yaml@53a9c808122ffaae9af948f72139fb4bd44ab74c
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
55 changes: 16 additions & 39 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,18 @@
name: goreleaser

---
name: "Release"
on:
push:
tags:
- "*"

permissions:
contents: write

workflow_dispatch:
pull_request_target:
types: [closed]
branches: [main]
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
## After having trouble with the PUBLISHER_TOKEN, I started down this path...
## But I never got the APP_ID to be accepted by the action
## Error: [@octokit/auth-app] appId option must be a number or numeric string
# - name: Generate token
# id: generate_token
# uses: tibdex/github-app-token@v1
# with:
# app_id: ${{ secrets.APP_ID }}
# private_key: ${{ secrets.APP_PEM }}
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.20.1
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf
with:
distribution: goreleaser
version: ${{ env.GITHUB_REF_NAME }}
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
release:
permissions:
contents: write
pull-requests: read
uses: jmeridth/reusable-workflows/.github/workflows/release.yaml@53a9c808122ffaae9af948f72139fb4bd44ab74c
with:
publish: true
release-config-name: release-drafter.yml
secrets:
github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/go-git/go-git/v5 v5.13.0
github.com/hashicorp/go-hclog v1.6.3
github.com/hashicorp/go-plugin v1.6.2
github.com/privateerproj/privateer-sdk v0.0.17
github.com/privateerproj/privateer-sdk v0.1.0
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
gopkg.in/yaml.v2 v2.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/privateerproj/privateer-sdk v0.0.17 h1:buTquGwlM3+lLggiaWUsOOxlPpNaYOYFv3R39HWN2ss=
github.com/privateerproj/privateer-sdk v0.0.17/go.mod h1:XC29QRTD3NqSVDby1wIVcd3rer5lFFn9I/8Px0xPsrs=
github.com/privateerproj/privateer-sdk v0.1.0 h1:b5/nx4mY3XJjKdsoqkgJMyERI/2af3sKdzongNUyZ10=
github.com/privateerproj/privateer-sdk v0.1.0/go.mod h1:XC29QRTD3NqSVDby1wIVcd3rer5lFFn9I/8Px0xPsrs=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand Down

0 comments on commit a0e47f4

Please sign in to comment.