Skip to content

Commit 616d768

Browse files
authored
Merge pull request #43 from TraGicCode/refactor-automated-release-process
Refactor automated release process
2 parents b434baa + 41d8a8d commit 616d768

File tree

4 files changed

+47
-49
lines changed

4 files changed

+47
-49
lines changed

.github/workflows/docker_build.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
name: Build and Publish Docker Image
22

33
on:
4-
workflow_call:
5-
inputs:
6-
version:
7-
required: true
8-
type: string
4+
push:
5+
tags:
6+
- 'v*'
97

108
permissions:
119
id-token: write
@@ -19,10 +17,13 @@ jobs:
1917
- name: Checkout
2018
uses: actions/checkout@v5
2119

20+
- name: Get semver without "v"
21+
id: version
22+
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
23+
2224
- name: Set up Docker Buildx
2325
uses: docker/setup-buildx-action@v3
2426

25-
2627
- name: Log in to Docker Hub
2728
uses: docker/login-action@v3
2829
with:
@@ -38,7 +39,7 @@ jobs:
3839
with:
3940
images: tragiccode/busly-cli
4041
tags: |
41-
${{ inputs.version }}
42+
${{ steps.version.outputs.VERSION }}
4243
latest
4344
4445
- name: Build and push Docker image
@@ -48,7 +49,7 @@ jobs:
4849
context: .
4950
file: ./src/BuslyCLI.Console/Dockerfile
5051
build-args: |
51-
APP_VERSION=${{ inputs.version }}
52+
APP_VERSION=${{ steps.version.outputs.VERSION }}
5253
push: true
5354
tags: ${{ steps.meta.outputs.tags }}
5455
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
name: Build and Publish .NET Tool
22

33
on:
4-
workflow_call:
5-
inputs:
6-
version:
7-
required: true
8-
type: string
9-
4+
push:
5+
tags:
6+
- 'v*'
107

118
jobs:
129
build-and-pack:
@@ -16,11 +13,15 @@ jobs:
1613
- name: Checkout
1714
uses: actions/checkout@v5
1815

16+
- name: Get semver without "v"
17+
id: version
18+
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
19+
1920
- name: Build and Pack as .NET tool
2021
uses: devcontainers/[email protected]
2122
with:
2223
runCmd: |
23-
dotnet cake --target Pack-DotNetTool --package-version ${{ inputs.version }}
24+
dotnet cake --target Pack-DotNetTool --package-version ${{ steps.version.outputs.VERSION }}
2425
2526
- name: Publish to NuGet (optional)
2627
run: dotnet nuget push ./artifacts/nupkgs/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}

.github/workflows/release.yml

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,42 @@ permissions:
88
id-token: write
99
attestations: write
1010

11-
1211
jobs:
13-
get-version:
12+
create-release:
1413
runs-on: ubuntu-latest
15-
outputs:
16-
version: ${{ steps.changelog.outputs.version }}
1714
steps:
18-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@v5
16+
with:
17+
fetch-depth: 0
1918

2019
- name: Extract version from CHANGELOG.md
2120
id: changelog
2221
run: |
2322
version=$(grep -m 1 -oP '^##\s*\[\K[0-9]+\.[0-9]+\.[0-9]+' CHANGELOG.md)
2423
echo "version=$version" >> $GITHUB_OUTPUT
25-
tag:
26-
needs: get-version
27-
runs-on: ubuntu-latest
28-
steps:
29-
- uses: actions/checkout@v5
30-
with:
31-
fetch-depth: 0
3224
33-
- name: Create and push git tag
25+
# - name: Create and push git tag
26+
# run: |
27+
# version=${{ steps.changelog.outputs.version }}
28+
29+
# git config user.name "github-actions[bot]"
30+
# git config user.email "github-actions[bot]@users.noreply.github.com"
31+
32+
# git tag "v$version"
33+
# git push origin "v$version"
34+
- name: "Generate Release Changelog"
3435
run: |
35-
version=${{ needs.get-version.outputs.version }}
36-
37-
git config user.name "github-actions[bot]"
38-
git config user.email "github-actions[bot]@users.noreply.github.com"
39-
40-
git tag "v$version"
41-
git push origin "v$version"
42-
docker:
43-
needs: get-version
44-
uses: ./.github/workflows/docker_build.yml
45-
with:
46-
version: ${{ needs.get-version.outputs.version }}
47-
secrets: inherit
48-
49-
nuget:
50-
needs: get-version
51-
uses: ./.github/workflows/dotnet_tool_build.yml
52-
with:
53-
version: ${{ needs.get-version.outputs.version }}
54-
secrets: inherit
36+
gh extension install chelnak/gh-changelog
37+
gh changelog new --latest
38+
39+
- name: Create GitHub Release
40+
id: create_release
41+
uses: actions/create-release@v1
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
with:
45+
tag_name: ${{ github.ref }}
46+
release_name: Release ${{ github.ref }}
47+
draft: false
48+
prerelease: false
49+
body_path: CHANGELOG.md

.github/workflows/release_prep.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: "The version number for the next release."
7+
description: "The version number for the next release (e.g. 1.0.2)"
88
required: true
9+
910
permissions:
1011
contents: write
1112
pull-requests: write

0 commit comments

Comments
 (0)