From 7cb5b0a0a6c137120e373e6364a2acc4d066324f Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Fri, 6 Dec 2024 13:04:19 -0500 Subject: [PATCH] Revert "fix: updated build script" This reverts commit deb14c63e527f05603a37dbe5cd2ee433996092f. --- .github/workflows/build.yml | 63 ++++++++--------------- .github/workflows/docker.yml | 97 ++++++++++++++++++++++++++++++++++++ .releaserc.json | 54 ++++++++++++++++++++ 3 files changed, 172 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/docker.yml create mode 100644 .releaserc.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6d61fd06..80a3b5c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,50 +24,29 @@ jobs: env: GITHUB_REF: ${{ github.ref }} - - name: Set Version Number and Phase + - 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: | - # Set initial version - latestVersion="2.0.0" - newVersion="$latestVersion" - phase="" - newVersionString="" - - # Output current GitHub Ref - echo "Current GitHub Ref: $GITHUB_REF" - - # Determine the phase and version string based on the branch - case $GITHUB_REF in - refs/pull/*) - phase="beta" - newVersionString="${newVersion}-${phase}-${GITHUB_RUN_NUMBER}" - ;; - refs/heads/hotfix-2.0.0/*) - phase="hotfix" - newVersionString="${newVersion}-${phase}-${GITHUB_RUN_NUMBER}" - ;; - refs/heads/release-2.0.0/*) - splitRef=(${GITHUB_REF//\// }) - version="${splitRef[-1]//v/}" - phase="rc" - newVersionString="${version}-${phase}-${GITHUB_RUN_NUMBER}" - ;; - refs/heads/feature-2.0.0/*) - phase="alpha" - newVersionString="${newVersion}-${phase}-${GITHUB_RUN_NUMBER}" - ;; - development-2.0.0) - phase="beta" - newVersionString="${newVersion}-${phase}-${GITHUB_RUN_NUMBER}" - ;; - esac - - # Output the final determined version and build phase - echo "Version to be used: $newVersionString" - echo "Build Phase: $phase" - - # Write the version to the GitHub environment file - echo "version=$newVersionString" >> $GITHUB_ENV + echo "# Summary" >> $GITHUB_STEP_SUMMARY + echo "No new version generated" >> $GITHUB_STEP_SUMMARY - name: Set up .NET uses: actions/setup-dotnet@v3 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..43419fd4 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,97 @@ +name: Branch Build Using Docker + +on: + push: + +env: + # solution path doesn't need slashes unless there it is multiple folders deep + # solution name does not include extension. .sln is assumed + SOLUTION_PATH: . + SOLUTION_FILE: PepperDash.Essentials + # Do not edit this, we're just creating it here + VERSION: 0.0.0-buildtype-buildnumber + # Defaults to debug for build type + BUILD_TYPE: Debug + # Defaults to main as the release branch. Change as necessary + RELEASE_BRANCH: main +jobs: + Build_Project_4-Series: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - name: Set Version Number + id: setVersion + shell: powershell + run: | + $latestVersion = [version]"2.0.0" + + $newVersion = [version]$latestVersion + $phase = "" + $newVersionString = "" + + Write-Host "Current GitHub Ref: $Env:GITHUB_REF" + + switch -regex ($Env:GITHUB_REF) { + '^refs\/pull\/*.' { + $phase = 'beta'; + $newVersionString = "{0}-{1}-{2}" -f $newVersion, $phase, $Env:GITHUB_RUN_NUMBER + } + '^refs\/heads\/hotfix-2.0.0\/*.' { + $phase = 'hotfix' + $newVersionString = "{0}-{1}-{2}" -f $newVersion, $phase, $Env:GITHUB_RUN_NUMBER + } + '^refs\/heads\/release-2.0.0\/*.' { + $splitRef = $Env:GITHUB_REF -split "/" + $version = [version]($splitRef[-1] -replace "v", "") + $phase = 'rc' + $newVersionString = "{0}-{1}-{2}" -f $version, $phase, $Env:GITHUB_RUN_NUMBER + } + '^refs\/heads\/feature-2.0.0\/*.' { + $phase = 'alpha' + $newVersionString = "{0}-{1}-{2}" -f $newVersion, $phase, $Env:GITHUB_RUN_NUMBER + } + 'development-2.0.0' { + $phase = 'beta' + $newVersionString = "{0}-{1}-{2}" -f $newVersion, $phase, $Env:GITHUB_RUN_NUMBER + } + } + + Write-Host "Version to be used: $newVersionString" + Write-Host "Build Phase: $phase" + + 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 + 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 }}" + - name: Create tag for non-rc builds + if: contains(steps.setVersion.outputs.version, 'alpha') + run: | + git tag ${{ steps.setVersion.outputs.version }} + git push --tags origin + # 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-') + uses: ncipollo/release-action@v1 + with: + artifacts: 'output\**\*.*(cpz|cplz)' + generateReleaseNotes: true + prerelease: ${{contains('debug', env.BUILD_TYPE)}} + tag: ${{ steps.setVersion.outputs.version }} + - name: Setup Nuget + 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 + - 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 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" + } + ] + ] +}