-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a30638
commit 2ccf6ee
Showing
2 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
paths: | ||
- '**.go' | ||
- 'go.mod' | ||
- 'go.sum' | ||
- '.github/workflows/release.yml' | ||
|
||
jobs: | ||
release: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
if: "!contains(github.event.head_commit.message, 'skip ci')" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' | ||
cache: true | ||
|
||
- name: Install dependencies | ||
run: go mod download | ||
|
||
- name: Run tests | ||
run: go test -v ./... | ||
|
||
- name: Get latest tag | ||
id: get_latest_tag | ||
run: | | ||
git fetch --tags | ||
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` 2>/dev/null || echo "v0.0.0") | ||
echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV | ||
- name: Bump version and push tag | ||
id: tag_version | ||
uses: mathieudutour/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
default_bump: patch | ||
default_prerelease_bump: patch | ||
release_branches: main | ||
tag_prefix: v | ||
|
||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
if: steps.tag_version.outputs.new_tag != steps.get_latest_tag.outputs.LATEST_TAG | ||
with: | ||
tag_name: ${{ steps.tag_version.outputs.new_tag }} | ||
name: Release ${{ steps.tag_version.outputs.new_tag }} | ||
body: | | ||
## What's Changed | ||
${{ steps.tag_version.outputs.changelog }} | ||
draft: false | ||
prerelease: false | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
paths: | ||
- '**.go' | ||
- 'go.mod' | ||
- 'go.sum' | ||
- '.github/workflows/test.yml' | ||
pull_request: | ||
branches: [ main ] | ||
paths: | ||
- '**.go' | ||
- 'go.mod' | ||
- 'go.sum' | ||
- '.github/workflows/test.yml' | ||
|
||
jobs: | ||
test: | ||
name: Run Tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
go-version: ['1.20', '1.21'] | ||
|
||
services: | ||
mongodb: | ||
image: mongo:latest | ||
ports: | ||
- 27017:27017 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
cache: true | ||
|
||
- name: Install dependencies | ||
run: go mod download | ||
|
||
- name: Run tests | ||
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
file: ./coverage.txt | ||
fail_ci_if_error: true | ||
token: ${{ secrets.CODECOV_TOKEN }} |