-
-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (97 loc) · 3.5 KB
/
release_1.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Release_1
on:
workflow_dispatch:
jobs:
create_release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.get_version.outputs.version }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Get Version
id: get_version
run: |
VERSION=$(grep -oP '(?<=<AssemblyVersion>).*(?=</AssemblyVersion>)' ZatcaEGS/ZatcaEGS.csproj)
echo "version=$VERSION" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.version }}
release_name: Release ${{ env.version }}
draft: false
prerelease: false
build:
needs: create_release
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
output_name: ZatcaEGS-linux
runtime: linux-x64
- os: windows-latest
output_name: ZatcaEGS-windows
runtime: win-x64
- os: macos-latest
output_name: ZatcaEGS-macos
runtime: osx-x64
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Display .NET Information
run: dotnet --info
- name: List Directory Contents
run: ls -R
- name: Restore dependencies
run: dotnet restore ZatcaEGS/ZatcaEGS.csproj
- name: Build
run: dotnet build ZatcaEGS/ZatcaEGS.csproj --configuration Release --no-restore
- name: Publish
run: dotnet publish ZatcaEGS/ZatcaEGS.csproj -c Release -o ./publish -r ${{ matrix.runtime }} --self-contained false
- name: Create macOS App Bundle
if: matrix.os == 'macos-latest'
run: |
mkdir -p ZatcaEGS.app/Contents/{MacOS,Resources}
cp ZatcaEGS/wwwroot/images/apple-icon.icns ZatcaEGS.app/Contents/Resources/
echo -e "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n <key>CFBundleExecutable</key>\n <string>ZatcaEGS</string>\n <key>CFBundleIconFile</key>\n <string>apple-icon</string>\n</dict>\n</plist>" > ZatcaEGS.app/Contents/Info.plist
cp ./publish/ZatcaEGS ZatcaEGS.app/Contents/MacOS/ZatcaEGS
chmod +x ZatcaEGS.app/Contents/MacOS/ZatcaEGS
- name: Zip Release
uses: thedoctor0/zip-release@master
with:
type: 'zip'
filename: ${{ matrix.output_name }}.zip
directory: ./publish
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./publish/${{ matrix.output_name }}.zip
asset_name: ${{ matrix.output_name }}.zip
asset_content_type: application/zip
- name: Upload logs if failed
if: failure()
uses: actions/upload-artifact@v3
with:
name: build-logs-${{ matrix.os }}
path: |
**/*.log
**/*.trx