-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: Create Release | ||
|
||
on: | ||
release: | ||
types: | ||
- created | ||
|
||
env: | ||
# Path to the solution file relative to the root of the project. | ||
SOLUTION_FILE_PATH: . | ||
TARGET_FILENAME: HexEdit.exe | ||
PACKAGE_PREFIX: HexEdit | ||
VERSION_H: src\\HexEdit\\version.h | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
configuration: [Release] | ||
platform: [x64, Win32] | ||
|
||
runs-on: windows-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set variables | ||
run: | ||
echo "TARGET_PATH=bin\${{matrix.platform}}\${{matrix.configuration}}\${{env.TARGET_FILENAME}}" | ||
"PACKAGE_NAME=./${{env.PACKAGE_PREFIX}}_${{matrix.configuration}}_${{matrix.platform}}.zip" | ||
| Out-File -FilePath $env:GITHUB_ENV | ||
|
||
- name: Setup MSBuild | ||
uses: microsoft/[email protected] | ||
|
||
- name: Increment version | ||
shell: python | ||
run: | | ||
import os | ||
import re | ||
r = re.match(r'v(\d+)\.(\d+)\.(\d+)', '${{github.ref_name}}') | ||
path = os.path.abspath("${{env.VERSION_H}}") | ||
with open(path, "w") as f: | ||
print("#define VERSION_MAJOR", r.group(1), file=f) | ||
print("#define VERSION_MIN", r.group(2), file=f) | ||
print("#define VERSION_BUILD", r.group(3), file=f) | ||
print("#define VERSION_BUILD_COUNT", ${{github.run_number}}, file=f) | ||
print("Writing: ", path) | ||
- name: Build | ||
working-directory: ${{env.GITHUB_WORKSPACE}} | ||
run: msbuild /m | ||
/p:Configuration=${{matrix.configuration}} | ||
/p:Platform=${{matrix.platform}} ${{env.SOLUTION_FILE_PATH}} | ||
|
||
- name: Package | ||
run: | ||
$compress = @{ | ||
Path = "${{env.TARGET_PATH}}", "LICENCE.TXT", "README.md"; | ||
CompressionLevel = "Optimal"; | ||
DestinationPath = "${{env.PACKAGE_NAME}}" | ||
}; | ||
Compress-Archive @compress | ||
|
||
- name: Publish | ||
run: gh release upload ${{github.ref_name}} ${{env.PACKAGE_NAME}} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|