From 9d7aa3db13acd1e427ffb02c15f0d115387d2891 Mon Sep 17 00:00:00 2001 From: Michael Fyffe <6224270+TraGicCode@users.noreply.github.com> Date: Tue, 18 Nov 2025 08:44:35 -0600 Subject: [PATCH] Refactor automated release process fix round 10 --- .../{docker_build.yml => docker_deploy.yml} | 25 +++++++++---- .github/workflows/dotnet_tool_build.yml | 28 -------------- .github/workflows/dotnet_tool_deploy.yml | 37 +++++++++++++++++++ .github/workflows/release.yml | 17 ++------- 4 files changed, 57 insertions(+), 50 deletions(-) rename .github/workflows/{docker_build.yml => docker_deploy.yml} (65%) delete mode 100644 .github/workflows/dotnet_tool_build.yml create mode 100644 .github/workflows/dotnet_tool_deploy.yml diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_deploy.yml similarity index 65% rename from .github/workflows/docker_build.yml rename to .github/workflows/docker_deploy.yml index 58f7e21..5435996 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_deploy.yml @@ -1,10 +1,8 @@ name: Build and Publish Docker Image on: - workflow_run: - workflows: [Release] - types: - - completed + release: + types: [published] permissions: id-token: write @@ -18,9 +16,20 @@ jobs: - name: Checkout uses: actions/checkout@v5 - - name: Get semver without "v" + - name: Extract version (without v) id: version - run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT + run: | + if [ "${{ github.event_name }}" = "release" ]; then + # Extract version from release tag (remove any 'v' prefix) + VERSION="${{ github.event.release.tag_name }}" + VERSION=${VERSION#v} # Remove 'v' prefix if present + else + VERSION="${{ github.event.inputs.version }}" + VERSION=${VERSION#v} # Remove 'v' prefix if present + fi + + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Syncing version: $VERSION" - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -40,7 +49,7 @@ jobs: with: images: tragiccode/busly-cli tags: | - ${{ steps.version.outputs.VERSION }} + ${{ steps.version.outputs.version }} latest - name: Build and push Docker image @@ -50,7 +59,7 @@ jobs: context: . file: ./src/BuslyCLI.Console/Dockerfile build-args: | - APP_VERSION=${{ steps.version.outputs.VERSION }} + APP_VERSION=${{ steps.version.outputs.version }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/dotnet_tool_build.yml b/.github/workflows/dotnet_tool_build.yml deleted file mode 100644 index b67fb60..0000000 --- a/.github/workflows/dotnet_tool_build.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Build and Publish .NET Tool - -on: - workflow_run: - workflows: [Release] - types: - - completed - -jobs: - build-and-pack: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v5 - - - name: Get semver without "v" - id: version - run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT - - - name: Build and Pack as .NET tool - uses: devcontainers/ci@v0.3 - with: - runCmd: | - dotnet cake --target Pack-DotNetTool --package-version ${{ steps.version.outputs.VERSION }} - - - name: Publish to NuGet (optional) - run: dotnet nuget push ./artifacts/nupkgs/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} diff --git a/.github/workflows/dotnet_tool_deploy.yml b/.github/workflows/dotnet_tool_deploy.yml new file mode 100644 index 0000000..9921e80 --- /dev/null +++ b/.github/workflows/dotnet_tool_deploy.yml @@ -0,0 +1,37 @@ +name: Build and Publish .NET Tool + +on: + release: + types: [published] + +jobs: + build-and-pack: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Extract version (without v) + id: version + run: | + if [ "${{ github.event_name }}" = "release" ]; then + # Extract version from release tag (remove any 'v' prefix) + VERSION="${{ github.event.release.tag_name }}" + VERSION=${VERSION#v} # Remove 'v' prefix if present + else + VERSION="${{ github.event.inputs.version }}" + VERSION=${VERSION#v} # Remove 'v' prefix if present + fi + + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Syncing version: $VERSION" + + - name: Build and Pack as .NET tool + uses: devcontainers/ci@v0.3 + with: + runCmd: | + dotnet cake --target Pack-DotNetTool --package-version ${{ steps.version.outputs.version }} + + - name: Publish to NuGet (optional) + run: dotnet nuget push ./artifacts/nupkgs/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1e52ce8..018ef86 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,17 +22,6 @@ jobs: version=$(grep -m 1 -oP '^##\s*\[\Kv[0-9]+\.[0-9]+\.[0-9]+' CHANGELOG.md) echo "version=$version" >> $GITHUB_OUTPUT - # - name: Create and push git tag - # run: | - # version=${{ steps.changelog.outputs.version }} - - # git config user.name "github-actions[bot]" - # git config user.email "github-actions[bot]@users.noreply.github.com" - - # git tag "v$version" - # git push origin "v$version" - - # gh changelog new --latest - name: "Generate Release Changelog" run: | @@ -44,12 +33,12 @@ jobs: # This creates a tag but doesn't trigger a "push event of the tag" FYI - name: Create GitHub Release id: create_release - uses: actions/create-release@v1 + uses: softprops/action-gh-release@v2 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GH_TOKEN_FOR_RELEASE_PUBLISH }} with: tag_name: ${{ steps.changelog.outputs.version }} - release_name: Release ${{ steps.changelog.outputs.version }} + name: Release ${{ steps.changelog.outputs.version }} draft: false prerelease: false body_path: CHANGELOG.md