Skip to content

Commit 8d6618e

Browse files
committed
Create release is now possible
[RELEASE] First release
1 parent de736c4 commit 8d6618e

File tree

1 file changed

+127
-22
lines changed

1 file changed

+127
-22
lines changed

.github/workflows/windows.yml

Lines changed: 127 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
- main
77

88
env:
9-
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
109
BUILD_TYPE: Release
1110
BOOST_TOOLSET: "msvc"
1211
BOOST_VERSION: "1.84.0"
@@ -15,44 +14,150 @@ env:
1514
jobs:
1615
build:
1716
runs-on: windows-2022
17+
permissions:
18+
contents: write
1819

1920
steps:
2021
- name: Checkout code
21-
uses: actions/checkout@v2
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 1
25+
fetch-tags: true
26+
27+
- name: Determine new version
28+
id: determine_version
29+
shell: pwsh
30+
run: |
31+
git fetch --tags
32+
try
33+
{
34+
$LAST_TAG = $(git describe --tags $(git rev-list --tags --max-count=1) 2>$null)
35+
}
36+
catch
37+
{
38+
$LAST_TAG = "none"
39+
$LAST_EXIT_CODE = $?
40+
}
41+
42+
if (-not $LAST_TAG)
43+
{
44+
$LAST_TAG = "none"
45+
}
46+
Write-Host "Last tag: $LAST_TAG"
47+
48+
$prerelease = $true
49+
50+
if ("${{ github.event.head_commit.message }}" -match "\[(RELEASE|MAJOR)\]")
51+
{
52+
$releaseType = $matches[1]
53+
echo "prerelease=false" >> $env:GITHUB_ENV
54+
}
55+
else
56+
{
57+
echo "prerelease=true" >> $env:GITHUB_ENV
58+
}
59+
60+
if ($LAST_TAG -eq "none")
61+
{
62+
if ($releaseType -eq "RELEASE")
63+
{
64+
$MAJOR = 1
65+
$MEDIUM = 0
66+
$MINOR = 0
67+
}
68+
elseif ($releaseType -eq "MAJOR")
69+
{
70+
$MAJOR = 0
71+
$MEDIUM = 1
72+
$MINOR = 0
73+
}
74+
else
75+
{
76+
$MAJOR = 0
77+
$MEDIUM = 0
78+
$MINOR = 1
79+
}
80+
}
81+
else
82+
{
83+
$MAJOR = [int]($LAST_TAG.Split(".")[0].TrimStart("v"))
84+
$MEDIUM = [int]($LAST_TAG.Split(".")[1])
85+
$MINOR = [int]($LAST_TAG.Split(".")[2])
86+
87+
if ($releaseType -eq "RELEASE")
88+
{
89+
$MAJOR++
90+
$MEDIUM = 0
91+
$MINOR = 0
92+
}
93+
elseif ($releaseType -eq "MAJOR")
94+
{
95+
$MEDIUM++
96+
$MINOR = 0
97+
}
98+
else
99+
{
100+
$MINOR++
101+
}
102+
}
103+
104+
$NEW_TAG = "v$MAJOR.$MEDIUM.$MINOR"
105+
Write-Host "New tag: $NEW_TAG"
106+
echo "tag=$NEW_TAG" >> $env:GITHUB_ENV
107+
108+
# Extract title if exists
109+
$TITLE = "Automated Release"
110+
$customTitleMatch = "${{ github.event.head_commit.message }}" -match "\[(RELEASE|MAJOR)\](.*)$"
111+
if ($customTitleMatch)
112+
{
113+
$CUSTOM_TITLE = $matches[2].Trim()
114+
if (-not [string]::IsNullOrWhiteSpace($CUSTOM_TITLE))
115+
{
116+
$TITLE = $CUSTOM_TITLE
117+
}
118+
}
119+
echo "title=$TITLE" >> $env:GITHUB_ENV
120+
121+
if ($LAST_EXIT_CODE -ne 0)
122+
{
123+
exit 0
124+
}
22125
23126
- name: Install Boost
24127
uses: MarkusJx/install-boost@v2.4.5
25128
id: install-boost
26129
with:
27-
# REQUIRED: Specify the required boost version
28-
# A list of supported versions can be found here:
29-
# https://github.com/MarkusJx/prebuilt-boost/blob/main/versions-manifest.json
30-
boost_version: ${{env.BOOST_VERSION}}
31-
# OPTIONAL: Specify a platform version
32-
platform_version: ${{env.BOOST_PLATFORM_VERSION}}
33-
# OPTIONAL: Specify a toolset
34-
toolset: ${{env.BOOST_TOOLSET}}
35-
# NOTE: If a boost version matching all requirements cannot be found,
36-
# this build step will fail
37-
38-
- name: Get specific version CMake, v3.28.0
39-
uses: lukka/get-cmake@v3.28.0
130+
boost_version: ${{ env.BOOST_VERSION }}
131+
platform_version: ${{ env.BOOST_PLATFORM_VERSION }}
132+
toolset: ${{ env.BOOST_TOOLSET }}
133+
134+
- name: Get specific version of CMake
135+
uses: lukka/get-cmake@latest
136+
with:
137+
cmakeVersion: '3.28.0'
40138

41139
- name: Configure CMake
42140
env:
43141
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
44-
run: cmake -Bbuild -A x64
142+
run: cmake -DBoost_NO_WARN_NEW_VERSIONS=1 -Bbuild -A x64
45143

46144
- name: Build application
47-
run: cmake --build build --config ${{env.BUILD_TYPE}}
145+
run: cmake --build build --config ${{ env.BUILD_TYPE }}
48146

49147
- name: Run tests
50148
run: |
51149
cd build
52-
ctest -C Release --output-on-failure
150+
ctest -C ${{ env.BUILD_TYPE }} --output-on-failure
151+
152+
- name: Get Current Date
153+
id: date
154+
run: echo "date=$(Get-Date -Format 'yyyy-MM-dd')" >> $env:GITHUB_ENV
53155

54-
- name: Publish artifacts
55-
uses: actions/upload-artifact@v2
156+
- name: Create and push tag
157+
uses: softprops/action-gh-release@v2
56158
with:
57-
name: Application
58-
path: build/src/parser/Release/Sql2CppHeader.exe
159+
files: build/src/parser/Release/Sql2CppHeader.exe
160+
tag_name: ${{ env.tag }}
161+
prerelease: ${{ env.prerelease }}
162+
name: "${{ env.title }} (${{ env.date }}) - ${{ env.tag }}"
163+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)