Skip to content

Commit c437a17

Browse files
committed
Added bump-my-version to release workflow
1 parent 3345d3b commit c437a17

File tree

2 files changed

+114
-21
lines changed

2 files changed

+114
-21
lines changed

.bumpversion.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[tool.bumpversion]
2+
current_version = "1.1.1"
3+
commit = true
4+
tag = true
5+
6+
[[tool.bumpversion.files]]
7+
filename = "src/framework.hpp"
8+
search = "static const char * VERSION = \"{current_version}\""
9+
replace = "static const char * VERSION = \"{new_version}\""

.github/workflows/build_release.yml

Lines changed: 105 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,117 @@ on:
55
types: [published]
66

77
workflow_dispatch:
8+
inputs:
9+
version_type:
10+
type: choice
11+
description: 'Version Type'
12+
required: true
13+
default: rebuild
14+
options:
15+
- rebuild
16+
- patch
17+
- minor
18+
- major
19+
publish_release:
20+
description: "Publish Release"
21+
type: boolean
22+
required: true
23+
default: true
824

925
jobs:
10-
build:
11-
name: Build
12-
permissions: write-all
26+
bump_version:
27+
name: Bump Version
28+
runs-on: ubuntu-latest
29+
permissions: write-all
30+
outputs:
31+
current_version: ${{ steps.get_version.outputs.current_version }}
32+
new_version: ${{ steps.bump.outputs.current-version || steps.bump_manual.outputs.current-version }}
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: fregante/setup-git-user@v2
36+
37+
- name: Install bump-my-version
38+
run: pip install bump-my-version
1339

14-
runs-on: windows-latest
40+
- name: Get current version
41+
id: get_version
42+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version_type == 'rebuild' }}
43+
run: echo "current_version=$(bump-my-version show current_version)" >> $GITHUB_OUTPUT
1544

16-
steps:
17-
- uses: actions/checkout@v4
45+
- name: Bump version
46+
id: bump
47+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version_type != 'rebuild' }}
48+
run: |
49+
echo "previous-version=$(bump-my-version show current_version)" >> $GITHUB_OUTPUT
50+
bump-my-version bump ${{ inputs.version_type }}
51+
([[ $? -gt 0 ]] && echo "bumped=false" || echo "bumped=true") >> $GITHUB_OUTPUT
52+
echo "current-version=$(bump-my-version show current_version)" >> $GITHUB_OUTPUT
1853
19-
- name: Add msbuild to PATH
20-
uses: microsoft/setup-msbuild@v2
54+
- name: Bump version (Manual)
55+
id: bump_manual
56+
if: ${{ github.event_name == 'release' }}
57+
run: |
58+
echo "previous-version=$(bump-my-version show current_version)" >> $GITHUB_OUTPUT
59+
bump-my-version bump --new-version ${{ github.ref_name }}
60+
([[ $? -gt 0 ]] && echo "bumped=false" || echo "bumped=true") >> $GITHUB_OUTPUT
61+
echo "current-version=$(bump-my-version show current_version)" >> $GITHUB_OUTPUT
2162
22-
- name: Integrate vcpkg
23-
run: vcpkg integrate install
63+
- name: Push changes to GitHub
64+
uses: ad-m/github-push-action@master
65+
with:
66+
force: true
2467

25-
- name: Build
26-
run: msbuild QuantumStreamer.sln -property:Configuration=Release
68+
build:
69+
name: Build
70+
permissions: write-all
71+
needs: bump_version
72+
runs-on: windows-latest
2773

28-
- name: Upload release artifact
29-
uses: actions/upload-artifact@v4
30-
with:
31-
name: ReleaseBuild
32-
path: x64\Release
74+
steps:
75+
- uses: actions/checkout@v4
76+
if: ${{ github.event_name == 'release' || github.event.inputs.version_type == 'rebuild' }}
3377

34-
- name: Upload Release
35-
uses: softprops/action-gh-release@v2
36-
with:
37-
files: ./x64/Release/loc_x64_f.dll
78+
- uses: actions/checkout@v4
79+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version_type != 'rebuild' }}
80+
with:
81+
ref: v${{ needs.bump_version.outputs.new_version }}
82+
83+
- name: Add msbuild to PATH
84+
uses: microsoft/setup-msbuild@v2
85+
86+
- name: Integrate vcpkg
87+
run: vcpkg integrate install
88+
89+
- name: Build
90+
run: msbuild QuantumStreamer.sln -property:Configuration=Release
91+
92+
- name: Upload release artifact
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: ReleaseBuild
96+
path: x64\Release
97+
98+
- name: Upload Release
99+
uses: softprops/action-gh-release@v2
100+
with:
101+
files: ./x64/Release/loc_x64_f.dll
102+
103+
- name: Upload Release (manual)
104+
if: ${{ github.event_name == 'release' }}
105+
uses: softprops/action-gh-release@v2
106+
with:
107+
files: ./x64/Release/loc_x64_f.dll
108+
109+
- name: Upload Release
110+
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.publish_release == 'true' && github.event.inputs.version_type != 'rebuild') || github.event_name == 'release' }}
111+
uses: softprops/action-gh-release@v2
112+
with:
113+
files: ./x64/Release/loc_x64_f.dll
114+
tag_name: v${{ needs.bump_version.outputs.new_version }}
115+
116+
- name: Upload Re-Release
117+
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.publish_release == 'true' && github.event.inputs.version_type == 'rebuild') && github.event_name != 'release' }}
118+
uses: softprops/action-gh-release@v2
119+
with:
120+
files: ./x64/Release/loc_x64_f.dll
121+
tag_name: v${{ needs.bump_version.outputs.current_version }}

0 commit comments

Comments
 (0)