Skip to content

Commit

Permalink
Changes to the versioning mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
tsutomi committed Jul 6, 2024
1 parent aef1770 commit a748837
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 16 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Release

permissions:
packages: write
contents: read

on:
release:
types: [ published ]
workflow_dispatch:
inputs:
version:
type: string
required: true
description: "The version of the package to release"

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [6.0.x, 7.0.x, 8.0.x]

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Install dependencies
run: dotnet restore

- name: Build
run: dotnet build -c Release --no-restore

- name: Test
run: dotnet test -c Release --no-build --no-restore

publish:
runs-on: ubuntu-latest
needs: build

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Extract the Version
run: echo "VERSION=$(echo ${{ github.event.release.tag_name }} | sed -e 's/^v//')" >> $GITHUB_ENV
if: github.event.release.tag_name != null

- name: Set the Version from Input
run: echo "VERSION=${{ inputs.version }}" >> $GITHUB_ENV
if: github.event.release.tag_name == null

- name: Install dependencies
run: dotnet restore

- name: Build
run: dotnet build -c Release --no-restore --version-suffix ${{ env.VERSION }}

- name: Pack
run: dotnet pack -c Release --no-build --no-restore --output ./pkgs --version-suffix ${{ env.VERSION }}

- name: Publish to GitHub Packages
run: dotnet nuget push ./pkgs/*.nupkg --source https://nuget.pkg.github.com/$GITHUB_REPOSITORY/ --api-key ${{ secrets.GITHUB_TOKEN }}

- name: Publish to NuGet
run: dotnet nuget push ./pkgs/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
18 changes: 2 additions & 16 deletions GitVersion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,17 @@ branches:
tag: ''
increment: Patch
regex: ^main$
source-branches: ['feature', 'release', 'hotfix']
source-branches: ['feature']
prevent-increment-of-merged-branch-version: true
tracks-release-branches: true
is-release-branch: true
feature:
tag: useBranchName
increment: Inherit
increment: None
regex: ^feature[-/]
source-branches: ['main']
tracks-release-branches: false
is-release-branch: false
release:
tag: rc
increment: None
regex: ^release[-/]
source-branches: ['main', 'feature']
tracks-release-branches: true
is-release-branch: true
hotfix:
tag: ''
increment: Patch
regex: ^hotfix[-/]
source-branches: ['main', 'release']
tracks-release-branches: false
is-release-branch: false
ignore:
sha: []
merge-message-formats: {}
Expand Down

0 comments on commit a748837

Please sign in to comment.