Skip to content

Commit 704e812

Browse files
committed
update pipeline
1 parent cee47c5 commit 704e812

2 files changed

Lines changed: 110 additions & 74 deletions

File tree

.github/workflows/build.yaml

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,56 @@
1-
name: "Build"
1+
name: CI
22

33
on:
44
push:
5-
branches:
6-
- master
7-
paths-ignore:
8-
- '**/*.md'
9-
- '**/*.gitignore'
10-
- '**/*.gitattributes'
11-
- '**/.github/workflows/release.yaml'
125
pull_request:
13-
branches:
14-
- master
15-
paths-ignore:
16-
- '**/*.md'
17-
- '**/*.gitignore'
18-
- '**/*.gitattributes'
19-
- '**/.github/workflows/release.yaml'
20-
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
2110
jobs:
22-
build:
11+
publish_windows:
12+
name: Publish (${{ matrix.rid }})
2313
runs-on: windows-latest
24-
permissions:
25-
contents: read
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
rid: [win-x64, win-x86]
18+
2619
steps:
27-
- uses: actions/checkout@v4
28-
- name: Setup .NET SDK
29-
uses: actions/setup-dotnet@v4
30-
with:
31-
dotnet-version: 8.0.x
32-
- name: Setup MSBuild
33-
uses: microsoft/setup-msbuild@v2
34-
- name: Cache NuGet packages
35-
uses: actions/cache@v4
20+
- name: Checkout
21+
uses: actions/checkout@v6
22+
23+
- name: Setup .NET
24+
uses: actions/setup-dotnet@v5
3625
with:
37-
path: ~/.nuget/packages
38-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
39-
restore-keys: |
40-
${{ runner.os }}-nuget-
41-
- name: Restore NuGet packages
42-
run: dotnet restore
43-
- name: Build project
44-
run: dotnet build --configuration Release --no-restore # Build the app in Release mode
45-
- name: Run tests
46-
run: dotnet test --configuration Release --no-build --verbosity normal # Run tests
47-
- name: Get short SHA
48-
run: echo "SHORT_SHA=$("${{ github.sha }}".SubString(0, 8))" >> $env:GITHUB_ENV
26+
global-json-file: global.json
27+
cache: true
28+
cache-dependency-path: |
29+
**/*.csproj
30+
31+
- name: Restore
32+
run: dotnet restore SOTFEdit.sln
33+
34+
- name: Test (Windows)
35+
run: dotnet test SOTFEdit.sln -c Release --no-restore --verbosity normal
36+
37+
- name: Publish (Windows)
38+
shell: pwsh
39+
env:
40+
RID: ${{ matrix.rid }}
41+
run: |
42+
Remove-Item -Recurse -Force dist -ErrorAction SilentlyContinue
43+
dotnet publish SOTFEdit/SOTFEdit.csproj -c Release -r $env:RID --self-contained false -o dist/$env:RID/SOTFEdit
44+
45+
- name: Package (Windows)
46+
shell: pwsh
47+
env:
48+
RID: ${{ matrix.rid }}
49+
run: |
50+
Compress-Archive -Path dist/$env:RID/* -DestinationPath SOTFEdit-$env:RID.zip -Force
51+
4952
- name: Upload artifact
50-
uses: actions/upload-artifact@v4
53+
uses: actions/upload-artifact@v6
5154
with:
52-
name: ${{ github.event.repository.name }}-${{ env.SHORT_SHA }}
53-
path: ${{ github.workspace }}/${{ github.event.repository.name }}/bin/Release/net8.0-windows/
55+
name: SOTFEdit-${{ matrix.rid }}
56+
path: SOTFEdit-${{ matrix.rid }}.zip

.github/workflows/release.yaml

Lines changed: 64 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,76 @@
1-
name: "Tag Release"
1+
name: Release
22

33
on:
44
push:
55
tags:
6-
- 'v*' # Push events to every tag not containing /
6+
- '*'
7+
8+
permissions:
9+
contents: write
10+
711
jobs:
812
build:
13+
name: Build assets (${{ matrix.rid }})
914
runs-on: windows-latest
10-
permissions:
11-
contents: write
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
rid: [win-x64, win-x86]
19+
1220
steps:
13-
- uses: actions/checkout@v4
14-
- name: Setup .NET SDK
15-
uses: actions/setup-dotnet@v4
21+
- name: Checkout
22+
uses: actions/checkout@v6
23+
24+
- name: Setup .NET
25+
uses: actions/setup-dotnet@v5
1626
with:
17-
dotnet-version: '8.0.x'
18-
- name: Setup MSBuild
19-
uses: microsoft/setup-msbuild@v2
20-
- name: Restore NuGet packages
21-
run: dotnet restore
22-
- name: Clean build directories
23-
run: dotnet clean --configuration Release
24-
- name: Run tests
25-
run: dotnet test --configuration Release --no-restore --verbosity normal # Run tests
26-
- name: Build project
27-
run: dotnet publish ${{ github.event.repository.name }} --configuration Release --no-restore --framework net8.0-windows --maxcpucount:1 # Build the app in Release mode
28-
- name: Create artifacts directory
27+
global-json-file: global.json
28+
cache: true
29+
cache-dependency-path: |
30+
**/*.csproj
31+
32+
- name: Restore
33+
run: dotnet restore SOTFEdit.sln
34+
35+
- name: Test (Windows)
36+
run: dotnet test SOTFEdit.sln -c Release --no-restore --verbosity normal
37+
38+
- name: Publish (Windows)
2939
shell: pwsh
30-
run: New-Item -ItemType Directory -Force -Path artifacts | Out-Null
31-
- name: Zip artifacts with PowerShell script
32-
shell: pwsh # Use PowerShell as the shell
40+
env:
41+
RID: ${{ matrix.rid }}
3342
run: |
34-
# Zip the output files with the assembly name and version
35-
Compress-Archive -Path ${{ github.workspace }}\${{ github.event.repository.name }}\bin\Release\net8.0-windows\publish\* -DestinationPath ${{ github.workspace }}\artifacts\${{ github.event.repository.name }}-${{ github.ref_name }}.zip
36-
- name: Create Release
37-
id: create_release
38-
uses: ncipollo/release-action@v1
43+
Remove-Item -Recurse -Force dist -ErrorAction SilentlyContinue
44+
dotnet publish SOTFEdit/SOTFEdit.csproj -c Release -r $env:RID --self-contained false -o dist/$env:RID/SOTFEdit
45+
46+
- name: Package (Windows)
47+
shell: pwsh
48+
env:
49+
RID: ${{ matrix.rid }}
50+
run: |
51+
Compress-Archive -Path dist/$env:RID/* -DestinationPath SOTFEdit-$env:RID.zip -Force
52+
53+
- name: Upload asset artifact
54+
uses: actions/upload-artifact@v6
55+
with:
56+
name: release-asset-${{ matrix.rid }}
57+
path: SOTFEdit-${{ matrix.rid }}.zip
58+
59+
release:
60+
name: Create GitHub Release
61+
runs-on: ubuntu-latest
62+
needs: build
63+
64+
steps:
65+
- name: Download assets
66+
uses: actions/download-artifact@v7
67+
with:
68+
path: release-assets
69+
merge-multiple: true
70+
71+
- name: Publish GitHub release
72+
uses: softprops/action-gh-release@v2
3973
with:
40-
artifacts: "artifacts/*"
41-
omitBody: true
42-
makeLatest: true
43-
generateReleaseNotes: true
74+
files: release-assets/*.zip
75+
fail_on_unmatched_files: true
76+
generate_release_notes: true

0 commit comments

Comments
 (0)