Skip to content

Commit

Permalink
Merge pull request #39 from babarot/babarot/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
babarot authored Jan 17, 2025
2 parents e63731a + 2c0702f commit 02f3cd7
Show file tree
Hide file tree
Showing 19 changed files with 383 additions and 201 deletions.
47 changes: 47 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Bug Report
description: Report a bug encountered while operating `gomi`
labels: kind/bug
body:
- type: textarea
id: problem
attributes:
label: What happened?
description: |
Please provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner.
validations:
required: true

- type: textarea
id: expected
attributes:
label: What did you expect to happen?
validations:
required: true

- type: textarea
id: repro
attributes:
label: How can we reproduce it (as minimally and precisely as possible)?
validations:
required: true

- type: textarea
id: additional
attributes:
label: Anything else we need to know?

- type: textarea
id: version
attributes:
label: version
value: |
<details>

```console
$ gomi --version
# paste output here
```

</details>
validations:
required: true
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## WHAT

<!-- write here -->

## WHY

<!-- write here -->
3 changes: 3 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
no-update-changelog:
- changed-files:
- any-glob-to-all-files: '!*.go'
30 changes: 30 additions & 0 deletions .github/labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# tag management - used by tagpr management
- name: tagpr
description: Used by tagpr for managing the release
color: ededed
- name: tagpr:minor
description: Used by tagpr for managing the release
color: ededed
- name: tagpr:major
description: Used by tagpr for managing the release
color: ededed
- name: no-update-changelog
description: Used in case of no need to update changelog
color: ededed

# kind/ - the type of issue
- name: kind/bug
description: A bug; unintended behavior
color: 425df5
- name: kind/feature
description: A feature request; new or enhanced behavior
color: 425df5
- name: kind/deprecation
description: Related to a feature or part of code being deprecated.
color: 425df5
- name: kind/cleanup
description: Categorizes issue or PR as related to cleaning up code, issues, etc.
color: 425df5
- name: kind/breaking-change
description: Denotes a PR that introduces potentially breaking changes that require user action.
color: 425df5
24 changes: 24 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
changelog:
exclude:
labels:
- tagpr
- no-update-changelog
categories:
- title: Breaking Changes
labels:
- kind/breaking-change
- title: New Features
labels:
- kind/feature
- title: Bug fixes
labels:
- kind/bug
- title: Deprecated features
labels:
- kind/deprecation
- title: Refactorings
labels:
- kind/cleanup
- title: Others
labels:
- "*"
16 changes: 16 additions & 0 deletions .github/workflows/add_labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Labels
on: pull_request

jobs:
triage:
timeout-minutes: 5
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/labeler@v5
with:
sync-labels: true
23 changes: 23 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Go
on:
pull_request:
workflow_dispatch:

jobs:
build:
strategy:
matrix:
go-version: ['stable']
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
runs-on: ${{ matrix.os }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Install Go
if: success()
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: true
- name: Run tests
run: make test
40 changes: 0 additions & 40 deletions .github/workflows/check-release.yaml

This file was deleted.

100 changes: 33 additions & 67 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,82 +4,48 @@ on:
push:
branches:
- main
- master

concurrency:
group: ${{ github.workflow }}

jobs:
release:
tagpr:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18

- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get pull request
uses: actions-ecosystem/action-get-merged-pull-request@v1
id: get-merged-pull-request
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Get release label
uses: actions-ecosystem/action-release-label@v1
id: release-label
if: ${{ steps.get-merged-pull-request.outputs.title != null }}
with:
labels: ${{ steps.get-merged-pull-request.outputs.labels }}

- name: Get latest Git tag
uses: actions-ecosystem/action-get-latest-tag@v1
id: get-latest-tag
if: ${{ steps.release-label.outputs.level != null }}
with:
semver_only: true
uses: actions/checkout@v4
- name: Run tagpr
uses: Songmu/tagpr@3dca11e7c0d68637ee212ddd35acc3d30a7403a4 # v1.5.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: run-tagpr
outputs:
tag: ${{ steps.run-tagpr.outputs.tag }}

- name: Bump up version
uses: actions-ecosystem/action-bump-semver@v1
id: bump-semver
if: ${{ steps.release-label.outputs.level != null }}
goreleaser:
if: needs.tagpr.outputs.tag != ''
needs: tagpr
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
current_version: ${{ steps.get-latest-tag.outputs.tag }}
level: ${{ steps.release-label.outputs.level }}

- name: Push new Git tag
uses: actions-ecosystem/action-push-tag@v1
if: ${{ steps.bump-semver.outputs.new_version != null }}
fetch-tags: true
- name: Setup Go
uses: actions/setup-go@v5
with:
tag: ${{ steps.bump-semver.outputs.new_version }}
message: "${{ steps.bump-semver.outputs.new_version }}: PR #${{ steps.get-merged-pull-request.outputs.number }} ${{ steps.get-merged-pull-request.outputs.title }}"

- name: Release binaries with GoReleaser
uses: goreleaser/goreleaser-action@v4
if: ${{ steps.release-label.outputs.level == 'major' || steps.release-label.outputs.level == 'minor' || steps.release-label.outputs.level == 'patch' }}
go-version-file: 'go.mod'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}

- name: Post release comment
uses: actions-ecosystem/action-create-comment@v1
if: ${{ steps.bump-semver.outputs.new_version != null }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.get-merged-pull-request.outputs.number }}
body: |
The new version [${{ steps.bump-semver.outputs.new_version }}](https://github.com/${{ github.repository }}/releases/tag/${{ steps.bump-semver.outputs.new_version }}) has been released :tada:
Changes: https://github.com/${{ github.repository }}/compare/${{ steps.get-latest-tag.outputs.tag }}...${{ steps.bump-semver.outputs.new_version }}
27 changes: 27 additions & 0 deletions .github/workflows/sync_labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Labels

on:
push:
branches:
- main
paths:
- '.github/labels.yaml'
workflow_dispatch:

permissions:
issues: write
contents: read

jobs:
sync:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Sync labels
uses: EndBug/label-sync@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
config-file: .github/labels.yaml
delete-other-labels: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gomi
Loading

0 comments on commit 02f3cd7

Please sign in to comment.