Skip to content

Commit 756ed02

Browse files
added tagging automation
1 parent 109a59e commit 756ed02

File tree

2 files changed

+91
-13
lines changed

2 files changed

+91
-13
lines changed

.github/workflows/release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Release wht.ps1
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'wht.ps1' # Only trigger if the script itself changes
9+
10+
permissions:
11+
contents: write
12+
13+
env:
14+
SCRIPT_NAME: "wht.ps1"
15+
16+
jobs:
17+
release:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set up Git identity
27+
run: |
28+
git config --global user.name "${{ github.actor }}"
29+
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
30+
31+
# Extract version from the specific script line: $scriptVersion = "x.x.x"
32+
- name: Extract version
33+
id: extract_version
34+
run: |
35+
NEW_VERSION=$(grep -Po '(?<=\$scriptVersion = ")([0-9]+\.[0-9]+\.[0-9]+)' ${{ env.SCRIPT_NAME }})
36+
echo "Detected version: $NEW_VERSION"
37+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
38+
39+
# Check if this version tag already exists to avoid errors/duplicates
40+
- name: Check if tag exists
41+
id: check_tag
42+
run: |
43+
if git rev-parse "v$NEW_VERSION" >/dev/null 2>&1; then
44+
echo "Tag v$NEW_VERSION already exists."
45+
echo "TAG_EXISTS=true" >> $GITHUB_ENV
46+
else
47+
echo "Tag v$NEW_VERSION does not exist. Proceeding with release."
48+
echo "TAG_EXISTS=false" >> $GITHUB_ENV
49+
fi
50+
51+
# Create the git tag and push it
52+
- name: Create and push tag
53+
if: env.TAG_EXISTS == 'false'
54+
run: |
55+
git tag -a "v$NEW_VERSION" -m "Release version $NEW_VERSION"
56+
git push origin "v$NEW_VERSION"
57+
58+
# Extract the .NOTES block for the release body
59+
- name: Extract release notes
60+
if: env.TAG_EXISTS == 'false'
61+
run: |
62+
RELEASE_NOTES=$(sed -n '/^.NOTES/,/^#>/p' ${{ env.SCRIPT_NAME }} | sed '1d;$d')
63+
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
64+
echo "$RELEASE_NOTES" >> $GITHUB_ENV
65+
echo "EOF" >> $GITHUB_ENV
66+
67+
# Create the GitHub Release (No files attached, just the tag and notes)
68+
- name: Create Release
69+
if: env.TAG_EXISTS == 'false'
70+
uses: softprops/action-gh-release@v2
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}
73+
with:
74+
tag_name: v${{ env.NEW_VERSION }}
75+
name: Release v${{ env.NEW_VERSION }}
76+
body: ${{ env.RELEASE_NOTES }}
77+
draft: false
78+
prerelease: false

wht.ps1

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@
44
.DESCRIPTION
55
A modern PowerShell script to toggle the WiFi hotspot on Windows 10/11
66
.NOTES
7-
rehauled main function
8-
minor fixes
7+
added tagging automation
98
#>
109

11-
# Script version
12-
$scriptVersion = "1.0.16"
10+
# ==== Script version ====
11+
$scriptVersion = "1.0.17"
12+
13+
# ==== Configuration ====
14+
$configFile = "$PSScriptRoot\adapter.config"
15+
$logFile = $true
16+
$logReverse = $false
17+
$logFilePath = "$PSScriptRoot\script.log"
18+
$restartWiFi = $false
19+
$forceAsAdmin = $true
20+
$delay = 30
1321

1422
# FORCE POWERSHELL 5.1 HANDOFF (Must come first to avoid Type errors in PS7)
1523
if ($PSVersionTable.PSVersion.Major -gt 5) {
@@ -36,15 +44,6 @@ try {
3644
Write-Warning "WinRT Type loading encountered an issue: $_"
3745
}
3846

39-
# ==== Configuration ====
40-
$configFile = "$PSScriptRoot\adapter.config"
41-
$logFile = $true
42-
$logReverse = $false
43-
$logFilePath = "$PSScriptRoot\script.log"
44-
$restartWiFi = $false
45-
$forceAsAdmin = $true
46-
$delay = 30
47-
4847
# ==== WinRT Helper Logic ====
4948
$RuntimeExtensions = [AppDomain]::CurrentDomain.GetAssemblies() |
5049
ForEach-Object { $_.GetType("System.WindowsRuntimeSystemExtensions") } |
@@ -233,3 +232,4 @@ LogThis "==== Done ===="
233232

234233

235234

235+

0 commit comments

Comments
 (0)