Skip to content

Commit 91dd507

Browse files
author
Matthew Bate
committed
Update Workflow Dev Releases
1 parent 18234c7 commit 91dd507

File tree

1 file changed

+39
-11
lines changed

1 file changed

+39
-11
lines changed

.github/workflows/dotnet-desktop.yml

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
name: Development Build and Publish
1+
# Add steps to generate a new tag based on the latest tag, timestamp, and commit hash,
2+
# then use that tag for the release.
3+
4+
name: Release Build and Publish
25

36
on:
7+
workflow_dispatch:
48
push:
5-
branches: [ master, main ]
69
tags:
710
- 'v*'
8-
pull_request:
9-
branches: [ master, main ]
10-
workflow_dispatch:
1111

1212
permissions:
1313
contents: write
@@ -39,6 +39,35 @@ jobs:
3939
- name: Setup .NET Framework Build Tools
4040
uses: microsoft/setup-msbuild@v2
4141

42+
# --- Tag Generation Section ---
43+
- name: Get latest tag
44+
id: get_tag
45+
shell: bash
46+
run: |
47+
latest_tag=$(git describe --tags --abbrev=0)
48+
echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV
49+
50+
- name: Generate timestamped tag
51+
id: gen_tag
52+
shell: bash
53+
run: |
54+
timestamp=$(date -u +"%m%d%H%M")
55+
commit=$(git rev-parse --short HEAD)
56+
new_tag="${LATEST_TAG}.${timestamp}-${commit}"
57+
echo "NEW_TAG=$new_tag" >> $GITHUB_ENV
58+
59+
- name: Create and push new tag
60+
shell: bash
61+
run: |
62+
git config user.name "github-actions"
63+
git config user.email "github-actions@github.com"
64+
git tag $NEW_TAG
65+
git push origin $NEW_TAG
66+
67+
- name: Set release version
68+
run: echo "VERSION=$NEW_TAG" >> $GITHUB_ENV
69+
# --- End Tag Generation Section ---
70+
4271
- name: Restore HawkSyncShared dependencies
4372
run: dotnet restore ${{ env.HAWKSYNCSHARED_PROJECT_PATH }}
4473

@@ -110,7 +139,7 @@ jobs:
110139
- name: Create version info
111140
shell: pwsh
112141
run: |
113-
$version = "dev-$(git rev-parse --short HEAD)"
142+
$version = "${{ env.VERSION }}"
114143
echo "VERSION=$version" >> $env:GITHUB_ENV
115144
116145
@"
@@ -159,15 +188,14 @@ jobs:
159188
path: ./${{ env.OUTPUT_NAME }}-${{ env.VERSION }}.zip
160189
retention-days: 30
161190

162-
- name: Create GitHub Pre-release
191+
- name: Create GitHub Release
163192
uses: softprops/action-gh-release@v2
164-
if: github.event_name != 'pull_request'
165193
with:
166194
tag_name: ${{ env.VERSION }}
167-
name: Pre-release Development Build ${{ env.VERSION }}
195+
name: Release ${{ env.VERSION }}
168196
body: |
169-
This is an automated pre-release development build for commit ${{ env.VERSION }}.
170-
prerelease: true
197+
This is an automated release build for ${{ env.VERSION }}.
198+
prerelease: false
171199
files: ./${{ env.OUTPUT_NAME }}-${{ env.VERSION }}.zip
172200
env:
173201
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)