Skip to content

Commit

Permalink
ci: update release process (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
danstis authored Jul 15, 2023
1 parent 5f8121d commit 38cc71f
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 68 deletions.
112 changes: 44 additions & 68 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,98 +1,74 @@
name: Build and Release
name: Build and Test

on:
push:
branches:
- main
- beta
- "feature/*"
- "fix/*"
pull_request:
branches:
- main
workflow_dispatch:

jobs:
version:
name: Generate version
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
FullSemVer: ${{ steps.gitversion.outputs.FullSemVer }}
PreReleaseTagWithDash: ${{ steps.gitversion.outputs.PreReleaseTagWithDash }}
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.x"
- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]
- name: Create annotation for build error
run: |
echo "::notice::FullSemVer ${{ steps.gitversion.outputs.FullSemVer }}"
echo "::notice::PreReleaseTagWithDash ${{ steps.gitversion.outputs.PreReleaseTagWithDash }}"
test:
name: Build and test
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ["1.x"]
steps:
- uses: actions/[email protected]
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Build
run: go build -race -v ./...
- name: Test
run: go test -race -v ./...
golangci:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v4
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ^1.20
- name: golangci-lint
uses: golangci/[email protected]
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
skip-pkg-cache: true
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
needs: [version]
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.x"
- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
with:
args: >
-Dsonar.projectVersion=${{ steps.gitversion.outputs.FullSemVer }}
-Dsonar.projectVersion=${{ needs.version.outputs.FullSemVer }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
build:
name: Release
runs-on: windows-2019
if: github.ref == 'refs/heads/main'
needs: [golangci]
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ^1.20
id: go

- name: Check out code into the Go module directory
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.x"

- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]

- name: Push version tag # https://github.com/marketplace/actions/commit-tagger
uses: tvdias/[email protected]
continue-on-error: true
if: ${{ steps.gitversion.outputs.PreReleaseTagWithDash == '' }}
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ steps.gitversion.outputs.FullSemVer }}

- name: Check out code
uses: actions/[email protected]
if: ${{ steps.gitversion.outputs.PreReleaseTagWithDash == '' }}
with:
fetch-depth: 0

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4 # https://github.com/marketplace/actions/goreleaser-action
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Create Release

on:
push:
branches:
- main
workflow_dispatch:

jobs:
version:
name: Generate version and tag
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
FullSemVer: ${{ steps.gitversion.outputs.FullSemVer }}
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.x"
- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]
- name: Create annotation for build error
run: |
echo "::notice::FullSemVer ${{ steps.gitversion.outputs.FullSemVer }}"
- name: Bump version and push tag # https://github.com/marketplace/actions/github-tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ steps.gitversion.outputs.FullSemVer }}
tag_prefix: v
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
needs: [version]
steps:
- uses: actions/[email protected]
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
with:
args: >
-Dsonar.projectVersion=${{ needs.version.outputs.FullSemVer }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
build:
name: Release
runs-on: windows-2019
needs: [version]
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ^1.20

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4 # https://github.com/marketplace/actions/goreleaser-action
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{.Tag}}-snapshot#{{.Commit}}"
release:
discussion_category_name: General
mode: append
prerelease: auto
changelog:
sort: asc
filters:
Expand Down

0 comments on commit 38cc71f

Please sign in to comment.