diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f43db00..916a88e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,8 +8,6 @@ on: push: branches: - main - tags: - - 'v*' pull_request: branches: - main @@ -72,12 +70,61 @@ jobs: - name: Package run: dotnet pack --no-build -c Release -o artifacts /p:Version="${{ steps.version.outputs.FullSemVer }}" - - name: Upload package to MyGet - if: steps.version.outputs.PreReleaseTag != '' && !github.event.act + # ------------------------------------------------------ + # PRE-RELEASE PACKAGES (ALPHA) — ONLY WHEN PR EXISTS + # ------------------------------------------------------ + - name: Upload package to MyGet (only in PR) + if: | + github.event_name == 'pull_request' && + steps.version.outputs.PreReleaseTag != '' && + !github.event.act run: dotnet nuget push "*.nupkg" -k ${{ secrets.MYGET_API_KEY }} -s https://www.myget.org/F/digillect/api/v3/index.json working-directory: artifacts - - name: Upload package to NuGet - if: steps.version.outputs.PreReleaseTag == '' && !github.event.act + # ------------------------------------------------------ + # RELEASE PACKAGES — ONLY WHEN PUSH TO MAIN + # ------------------------------------------------------ + - name: Upload package to NuGet (only push to main) + if: | + github.event_name == 'push' && + github.ref == 'refs/heads/main' && + steps.version.outputs.PreReleaseTag == '' && + !github.event.act run: dotnet nuget push "*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json - working-directory: artifacts \ No newline at end of file + working-directory: artifacts + + # --------------------------------------------- + # CREATE TAG FOR RELEASE + # --------------------------------------------- + - name: Create Git Tag + if: | + github.event_name == 'push' && + github.ref == 'refs/heads/main' && + steps.version.outputs.PreReleaseTag == '' && + !github.event.act + run: | + git config user.name "github-actions" + git config user.email "github-actions@github.com" + + TAG="v${{ steps.version.outputs.FullSemVer }}" + git tag $TAG + git push origin $TAG + + # --------------------------------------------- + # CREATE GITHUB RELEASE + # --------------------------------------------- + - name: Create GitHub Release + if: | + github.event_name == 'push' && + github.ref == 'refs/heads/main' && + steps.version.outputs.PreReleaseTag == '' && + !github.event.act + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ steps.version.outputs.FullSemVer }} + name: Release ${{ steps.version.outputs.FullSemVer }} + body: | + ## Changes in this release + ${{ steps.version.outputs.Changelog }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/GitVersion.yml b/GitVersion.yml index 85ca5c6..28ce310 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,23 +1,23 @@ -assembly-versioning-scheme: MajorMinorPatch +mode: ContinuousDeployment strategies: - MergeMessage - TaggedCommit - Mainline - Fallback + branches: main: - regex: ^master$|^main$ - label: alpha + regex: ^main$ increment: Patch - is-release-branch: false - is-main-branch: true - tags: - regex: ^tags/v.+$ - label: '' - source-branches: ['main'] - increment: None is-release-branch: true - is-main-branch: true + + feature: + regex: ^feature[/-] + increment: Minor + is-release-branch: false + label: alpha + ignore: sha: [] -merge-message-formats: {} \ No newline at end of file + +commit-message-incrementing: Enabled \ No newline at end of file