mirror of
https://github.com/lukaszraczylo/kportal.git
synced 2026-07-11 07:22:15 +00:00
Move build and release to shared workflow
This commit is contained in:
@@ -5,90 +5,18 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths:
|
paths:
|
||||||
- '**.go'
|
- "**.go"
|
||||||
- 'go.mod'
|
- "go.mod"
|
||||||
- 'go.sum'
|
- "go.sum"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
|
||||||
name: Test
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Go
|
|
||||||
uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: '1.23'
|
|
||||||
|
|
||||||
- name: Run tests with race detector
|
|
||||||
run: go test -race -v ./...
|
|
||||||
|
|
||||||
version:
|
|
||||||
name: Calculate Version
|
|
||||||
needs: test
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
version: ${{ steps.version_formatted.outputs.version }}
|
|
||||||
version_tag: ${{ steps.version_formatted.outputs.version_tag }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Calculate semantic version
|
|
||||||
id: semver
|
|
||||||
uses: lukaszraczylo/semver-generator@v1
|
|
||||||
with:
|
|
||||||
config_file: semver.yaml
|
|
||||||
repository_local: true
|
|
||||||
|
|
||||||
- name: Format version
|
|
||||||
id: version_formatted
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.semver.outputs.semantic_version }}"
|
|
||||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
||||||
echo "version_tag=v${VERSION}" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Display version
|
|
||||||
run: |
|
|
||||||
echo "Calculated version: ${{ steps.version_formatted.outputs.version }}"
|
|
||||||
echo "Version tag: ${{ steps.version_formatted.outputs.version_tag }}"
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
name: Release with GoReleaser
|
uses: lukaszraczylo/shared-actions/.github/workflows/go-release.yaml@main
|
||||||
needs: version
|
with:
|
||||||
runs-on: ubuntu-latest
|
go-version: "1.23"
|
||||||
steps:
|
secrets:
|
||||||
- name: Checkout code
|
homebrew-tap-token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Go
|
|
||||||
uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: '1.23'
|
|
||||||
|
|
||||||
- name: Create and push tag
|
|
||||||
run: |
|
|
||||||
git config user.name "github-actions[bot]"
|
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
||||||
git tag -a ${{ needs.version.outputs.version_tag }} -m "Release ${{ needs.version.outputs.version_tag }}"
|
|
||||||
git push origin ${{ needs.version.outputs.version_tag }}
|
|
||||||
|
|
||||||
- name: Run GoReleaser
|
|
||||||
uses: goreleaser/goreleaser-action@v6
|
|
||||||
with:
|
|
||||||
distribution: goreleaser
|
|
||||||
version: '~> v2'
|
|
||||||
args: release --clean
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user