-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (66 loc) · 2.75 KB
/
dev.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Dev SingleFile x64 App
on:
push:
branches: [ dev ] # Set this to trigger on pushes to the dev branch
workflow_dispatch: # This line enables manual triggering of the workflow
permissions:
contents: write
jobs:
build-and-test:
runs-on: windows-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.x' # Replace with the .NET version your project targets
- name: Build Solution
run: dotnet build --configuration Release
- name: Run Tests
run: dotnet test
- name: Publish Application
run: dotnet publish --configuration Release -o ./publish -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained=false
- name: Upload Published App as Artifact
uses: actions/upload-artifact@v2
with:
name: dev-published-app
path: ./publish/**
# Extract Version Information from .csproj
- name: Extract version
id: extract_version
run: |
$version = [xml](Get-Content ./DeFRaG_Helper/DeFRaG_Helper.csproj)
$assemblyVersion = $version.Project.PropertyGroup.AssemblyVersion
echo "Extracted version is $assemblyVersion"
echo "::set-output name=ASSEMBLY_VERSION::$assemblyVersion"
shell: pwsh
- name: Delete Existing Release 'Dev Release' if it Exists
run: |
RELEASE_ID=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/tags/dev-${{ steps.extract_version.outputs.ASSEMBLY_VERSION }} \
| jq '.id')
if [ "$RELEASE_ID" != "null" ]; then
curl -X DELETE -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID
fi
shell: bash
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: dev-${{ steps.extract_version.outputs.ASSEMBLY_VERSION }} # Prefix the tag to differentiate from master releases
release_name: Dev Release ${{ steps.extract_version.outputs.ASSEMBLY_VERSION }}
draft: false
prerelease: true # Mark it as a pre-release
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./publish/DeFRaG_Helper.exe
asset_name: DeFRaG_Helper_dev_${{ steps.extract_version.outputs.ASSEMBLY_VERSION }}.exe
asset_content_type: application/octet-stream