44 push :
55 tags : ["v*"]
66 workflow_dispatch :
7- inputs :
8- tag :
9- description : " Tag to release"
10- required : false
11- default : " v0.0.0"
7+ inputs :
8+ tag :
9+ description : " Tag to release"
10+ required : false
11+ default : " v0.0.0"
1212
1313permissions :
1414 contents : write
@@ -39,53 +39,22 @@ jobs:
3939 target : x86_64-pc-windows-msvc
4040 asset_name : windows
4141 arch : x86_64
42+ env :
43+ BINARY_NAME : keywatch-${{ matrix.platform.asset_name }}-${{ matrix.platform.arch }}${{ matrix.platform.os == 'windows-latest' && '.exe' || '' }}
4244
4345 steps :
4446 - name : Checkout repository
4547 uses : actions/checkout@v4
4648 with :
4749 fetch-depth : 0
4850
49- # Determine the release version:
50- # If triggered by workflow_dispatch then use the input tag,
51- # otherwise extract the version from the pushed tag.
52- - name : Set Release Version
53- id : set-version
54- run : |
55- if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
56- VERSION="${{ github.event.inputs.tag }}"
57- else
58- # Remove the leading refs/tags/ from the ref.
59- VERSION="${GITHUB_REF#refs/tags/}"
60- fi
61- echo "VERSION=${VERSION}" >> $GITHUB_ENV
62- echo "Version is ${VERSION}"
63-
64- # This step sets up a simpler way to compute the binary name.
65- - name : Set Binary Name
66- id : set-binary-name
67- shell : bash
68- run : |
69- if [ "${{ matrix.platform.os }}" == "windows-latest" ]; then
70- ext=".exe"
71- else
72- ext=""
73- fi
74- BINARY_NAME="keywatch-${{ matrix.platform.asset_name }}-${{ matrix.platform.arch }}${ext}"
75- echo "BINARY_NAME=${BINARY_NAME}" >> $GITHUB_ENV
76- echo "Binary name set to ${BINARY_NAME}"
77-
78- # Extract Release Notes only once (on Linux) using the updated AWK script.
7951 - name : Extract Release Notes
8052 id : release-notes
8153 if : matrix.platform.os == 'ubuntu-latest'
8254 run : |
55+ VERSION=${GITHUB_REF#refs/tags/}
8356 NOTES=$(awk -v ver="$VERSION" '
84- /^## \[/ {
85- if (p) { exit }
86- # Expecting header format like "## [v1.2.3]"
87- if ($2 == "[" ver "]") { p=1; next }
88- }
57+ /^## \[/ { if (p) { exit }; if ($2 == "['ver']") { p=1; next } }
8958 p { print }
9059 ' CHANGELOG.md)
9160 echo "NOTES<<EOF" >> $GITHUB_OUTPUT
11079 run : |
11180 mkdir -p release
11281 cp target/${{ matrix.platform.target }}/release/key-watch${{ matrix.platform.os == 'windows-latest' && '.exe' || '' }} \
113- release/${BINARY_NAME}
82+ release/${{ env. BINARY_NAME } }
11483
11584 # Windows: Generate checksum using cmd and Windows syntax.
11685 - name : Generate SHA-256 (Windows)
@@ -132,10 +101,10 @@ jobs:
132101 - name : Create Release
133102 uses : softprops/action-gh-release@v1
134103 with :
135- name : " KeyWatch ${VERSION }"
104+ name : " KeyWatch ${{ github.ref_name } }"
136105 files : |
137- release/${BINARY_NAME}
138- release/${BINARY_NAME}.sha256
106+ release/${{ env. BINARY_NAME } }
107+ release/${{ env. BINARY_NAME } }.sha256
139108 body : ${{ steps.release-notes.outputs.NOTES }}
140109 draft : false
141110 prerelease : false
0 commit comments