From 41d8a8d03382c6d1ad20ccb83aee38b55b75f820 Mon Sep 17 00:00:00 2001 From: Michael Fyffe <6224270+TraGicCode@users.noreply.github.com> Date: Mon, 17 Nov 2025 22:57:02 -0600 Subject: [PATCH] Refactor automated release process --- .github/workflows/docker_build.yml | 17 +++---- .github/workflows/dotnet_tool_build.yml | 15 +++--- .github/workflows/release.yml | 61 ++++++++++++------------- .github/workflows/release_prep.yml | 3 +- 4 files changed, 47 insertions(+), 49 deletions(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index acaac5fb..55d46722 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -1,11 +1,9 @@ name: Build and Publish Docker Image on: - workflow_call: - inputs: - version: - required: true - type: string + push: + tags: + - 'v*' permissions: id-token: write @@ -19,10 +17,13 @@ jobs: - name: Checkout uses: actions/checkout@v5 + - name: Get semver without "v" + id: version + run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Log in to Docker Hub uses: docker/login-action@v3 with: @@ -38,7 +39,7 @@ jobs: with: images: tragiccode/busly-cli tags: | - ${{ inputs.version }} + ${{ steps.version.outputs.VERSION }} latest - name: Build and push Docker image @@ -48,7 +49,7 @@ jobs: context: . file: ./src/BuslyCLI.Console/Dockerfile build-args: | - APP_VERSION=${{ inputs.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 index 038fe640..b55ed304 100644 --- a/.github/workflows/dotnet_tool_build.yml +++ b/.github/workflows/dotnet_tool_build.yml @@ -1,12 +1,9 @@ name: Build and Publish .NET Tool on: - workflow_call: - inputs: - version: - required: true - type: string - + push: + tags: + - 'v*' jobs: build-and-pack: @@ -16,11 +13,15 @@ jobs: - 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 ${{ inputs.version }} + 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 ce9f4a3a..d89ae3cf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,47 +8,42 @@ permissions: id-token: write attestations: write - jobs: - get-version: + create-release: runs-on: ubuntu-latest - outputs: - version: ${{ steps.changelog.outputs.version }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 + with: + fetch-depth: 0 - name: Extract version from CHANGELOG.md id: changelog run: | version=$(grep -m 1 -oP '^##\s*\[\K[0-9]+\.[0-9]+\.[0-9]+' CHANGELOG.md) echo "version=$version" >> $GITHUB_OUTPUT - tag: - needs: get-version - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - with: - fetch-depth: 0 - - name: Create and push git tag + # - 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" + - name: "Generate Release Changelog" run: | - version=${{ needs.get-version.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" - docker: - needs: get-version - uses: ./.github/workflows/docker_build.yml - with: - version: ${{ needs.get-version.outputs.version }} - secrets: inherit - - nuget: - needs: get-version - uses: ./.github/workflows/dotnet_tool_build.yml - with: - version: ${{ needs.get-version.outputs.version }} - secrets: inherit + gh extension install chelnak/gh-changelog + gh changelog new --latest + + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + body_path: CHANGELOG.md diff --git a/.github/workflows/release_prep.yml b/.github/workflows/release_prep.yml index f3feed3e..609f66ae 100644 --- a/.github/workflows/release_prep.yml +++ b/.github/workflows/release_prep.yml @@ -4,8 +4,9 @@ on: workflow_dispatch: inputs: version: - description: "The version number for the next release." + description: "The version number for the next release (e.g. 1.0.2)" required: true + permissions: contents: write pull-requests: write