From f91ca7807c4f346cebb85dfbea5051a970a3d177 Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Fri, 6 Dec 2024 11:49:30 -0500 Subject: [PATCH] feat: working on updated build --- .github/workflows/build.yml | 86 ++++++++++++++++++++++++++++++++++++ .github/workflows/docker.yml | 23 ++++------ .releaserc.json | 54 ++++++++++++++++++++++ 3 files changed, 149 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .releaserc.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..80a3b5c7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,86 @@ +name: Essentials Plugin Build Get Version + +on: + push: + branches: + - feature-2.0.0/* + - hotfix-2.0.0/* + - release-2.0.0/* + - development-2.0.0 + +jobs: + Build_Project_4-Series: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Get branch name + id: get_branch + run: | + branch=${GITHUB_REF#refs/heads/} + echo "branch=$branch" >> $GITHUB_OUTPUT + echo "prerelease=${branch//\//-}" >> $GITHUB_OUTPUT + env: + GITHUB_REF: ${{ github.ref }} + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "lts/*" + + - name: Install dependencies + run: "npm install -g + semantic-release @semantic-release/commit-analyzer @semantic-release/release-notes-generator + @semantic-release/changelog @semantic-release/exec conventional-changelog-conventionalcommits" + + - name: Run semantic-release + id: get_version + run: npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Print summary if no new version + if: steps.get_version.outputs.newVersion != 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN}} + run: | + echo "# Summary" >> $GITHUB_STEP_SUMMARY + echo "No new version generated" >> $GITHUB_STEP_SUMMARY + + - name: Set up .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: "8.x" + + - name: Restore .NET dependencies + run: dotnet restore + + - name: Build .NET project + run: dotnet build --configuration Release -p:Version=${{ steps.get_version.outputs.version }} + + - name: Pack .NET project + run: dotnet pack --configuration Release -p:Version=${{ steps.get_version.outputs.version }} --output ./output + + - run: ls -la + + - name: Create Release + id: create_release + if: steps.get_version.outputs.newVersion == 'true' + uses: ncipollo/release-action@v1 + with: + prerelease: ${{ steps.get_branch.outcome.branch != 'main' }} + artifacts: "output/**/*.*(cpz|cplz)" + tag: ${{ steps.get_version.outputs.tag }} + commit: ${{ github.sha }} + bodyFile: ./CHANGELOG.md + + - name: Print results + if: steps.get_version.outputs.newVersion == 'true' + run: | + echo "# Summary" >> $GITHUB_STEP_SUMMARY + echo "Version: ${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY + echo "Tag: ${{ steps.get_version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY + echo "New Version: ${{ steps.get_version.outputs.newVersion }}" >> $GITHUB_STEP_SUMMARY + echo "Channel: ${{ steps.get_version.outputs.channel }}" >> $GITHUB_STEP_SUMMARY + echo "Type: ${{ steps.get_version.outputs.type }}" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8006d65c..43419fd4 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,11 +2,6 @@ name: Branch Build Using Docker on: push: - branches: - - feature-2.0.0/* - - hotfix-2.0.0/* - - release-2.0.0/* - - development-2.0.0 env: # solution path doesn't need slashes unless there it is multiple folders deep @@ -22,7 +17,7 @@ env: jobs: Build_Project_4-Series: runs-on: windows-latest - steps: + steps: - uses: actions/checkout@v3 - name: Set Version Number id: setVersion @@ -64,13 +59,13 @@ jobs: Write-Host "Version to be used: $newVersionString" Write-Host "Build Phase: $phase" - echo "version=$newVersionString" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + echo "version=$newVersionString" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - name: Setup MS Build uses: microsoft/setup-msbuild@v1.1 - name: restore Nuget Packages run: nuget restore .\$($Env:SOLUTION_FILE).sln # Build the solutions in the docker image - - name: Build Solution + - name: Build Solution run: msbuild .\$($Env:SOLUTION_FILE).sln /p:Platform="Any CPU" /p:Configuration="Debug" /p:Version="${{ steps.setVersion.outputs.version }}" -m - name: Pack Solution run: dotnet pack .\$($Env:SOLUTION_FILE).sln --configuration $env:BUILD_TYPE --output ./output /p:Version="${{ steps.setVersion.outputs.version }}" @@ -82,9 +77,9 @@ jobs: # Create the release on the source repo - name: Create Release id: create_release -# if: contains(steps.setVersion.outputs.version,'-rc-') || -# contains(steps.setVersion.outputs.version,'-hotfix-') || -# contains(steps.setVersion.outputs.version, '-beta-') + # if: contains(steps.setVersion.outputs.version,'-rc-') || + # contains(steps.setVersion.outputs.version,'-hotfix-') || + # contains(steps.setVersion.outputs.version, '-beta-') uses: ncipollo/release-action@v1 with: artifacts: 'output\**\*.*(cpz|cplz)' @@ -92,11 +87,11 @@ jobs: prerelease: ${{contains('debug', env.BUILD_TYPE)}} tag: ${{ steps.setVersion.outputs.version }} - name: Setup Nuget - run: | + run: | nuget sources add -name github -source https://nuget.pkg.github.com/pepperdash/index.json -username pepperdash -password ${{ secrets.GITHUB_TOKEN }} nuget setApiKey ${{ secrets.GITHUB_TOKEN }} -Source github - nuget setApiKey ${{ secrets.NUGET_API_KEY }} -Source https://api.nuget.org/v3/index.json + nuget setApiKey ${{ secrets.NUGET_API_KEY }} -Source https://api.nuget.org/v3/index.json - name: Publish to Nuget run: nuget push .\output\*.nupkg -Source https://api.nuget.org/v3/index.json - name: Publish to Github Nuget - run: nuget push .\output\*.nupkg -Source github \ No newline at end of file + run: nuget push .\output\*.nupkg -Source github diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 00000000..cf6a6c69 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,54 @@ +{ + "branches": [ + { + "name": "development-2.0.0", + "prerelease": true + }, + { + "name": "feature-2.0.0/*", + "prerelease": "beta" + }, + { + "name": "hotfix-2.0.0/*", + "prerelease": "patch" + }, + { + "name": "release-2.0.0/*", + "prerelease": "rc" + } + ], + "plugins": [ + "@semantic-release/commit-analyzer", + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { "type": "feat", "section": "๐Ÿš€ Features" }, + { "type": "fix", "section": "๐Ÿ› Bug Fixes" }, + { "type": "chore", "section": "๐Ÿงน Maintenance" }, + { "type": "docs", "section": "๐Ÿ“š Documentation" }, + { "type": "style", "section": "๐Ÿ’Ž Code Style" }, + { "type": "refactor", "section": "๐Ÿ”จ Refactoring" }, + { "type": "perf", "section": "โšก Performance Improvements" }, + { "type": "test", "section": "โœ… Tests" } + ] + } + } + ], + [ + "@semantic-release/changelog", + { + "changelogTitle": "# ๐Ÿ“ฆ Release History\n\nAll notable changes to this project will be documented in this file." + } + ], + [ + "@semantic-release/exec", + { + "verifyReleaseCmd": "echo \"newVersion=true\" >> $GITHUB_OUTPUT", + "publishCmd": "echo \"version=${nextRelease.version}\" >> $GITHUB_OUTPUT && echo \"tag=${nextRelease.gitTag}\" >> $GITHUB_OUTPUT && echo \"type=${nextRelease.type}\" >> $GITHUB_OUTPUT && echo \"channel=${nextRelease.channel}\" >> $GITHUB_OUTPUT" + } + ] + ] +}