1+ name : Release
2+
3+ on :
4+ push :
5+ tags :
6+ - ' v*'
7+
8+ env :
9+ PROJECT_PATH : ' src/LinkValidator'
10+
11+ jobs :
12+ build :
13+ name : Build Release Binaries
14+ runs-on : ubuntu-latest
15+ strategy :
16+ matrix :
17+ runtime : [win-x64, linux-x64, osx-x64, osx-arm64]
18+ include :
19+ - runtime : win-x64
20+ extension : ' .exe'
21+ archive-name : ' link-validator-windows-x64'
22+ - runtime : linux-x64
23+ extension : ' '
24+ archive-name : ' link-validator-linux-x64'
25+ - runtime : osx-x64
26+ extension : ' '
27+ archive-name : ' link-validator-macos-x64'
28+ - runtime : osx-arm64
29+ extension : ' '
30+ archive-name : ' link-validator-macos-arm64'
31+
32+ steps :
33+ - name : Checkout
34+ uses : actions/checkout@v4
35+ with :
36+ fetch-depth : 0
37+
38+ - name : Setup .NET
39+ uses : actions/setup-dotnet@v4
40+ with :
41+ global-json-file : global.json
42+
43+ - name : Update version info from release notes
44+ run : pwsh ./build.ps1
45+
46+ - name : Restore dependencies
47+ run : dotnet restore
48+
49+ - name : Build and publish
50+ run : |
51+ dotnet publish ${{ env.PROJECT_PATH }} \
52+ -c Release \
53+ -r ${{ matrix.runtime }} \
54+ --self-contained false \
55+ -o publish/${{ matrix.runtime }}
56+
57+ - name : Create archive
58+ run : |
59+ cd publish/${{ matrix.runtime }}
60+ if [ "${{ matrix.runtime }}" == "win-x64" ]; then
61+ zip -r ../../${{ matrix.archive-name }}.zip link-validator${{ matrix.extension }}
62+ else
63+ tar -czf ../../${{ matrix.archive-name }}.tar.gz link-validator${{ matrix.extension }}
64+ fi
65+
66+ - name : Upload artifact
67+ uses : actions/upload-artifact@v4
68+ with :
69+ name : ${{ matrix.archive-name }}
70+ path : |
71+ ${{ matrix.archive-name }}.zip
72+ ${{ matrix.archive-name }}.tar.gz
73+ if-no-files-found : ignore
74+
75+ release :
76+ name : Create Release
77+ needs : build
78+ runs-on : ubuntu-latest
79+ permissions :
80+ contents : write
81+
82+ steps :
83+ - name : Checkout
84+ uses : actions/checkout@v4
85+
86+ - name : Download all artifacts
87+ uses : actions/download-artifact@v4
88+ with :
89+ path : artifacts
90+
91+ - name : Extract version from tag
92+ id : version
93+ run : echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
94+
95+ - name : Read release notes
96+ id : release_notes
97+ run : |
98+ if [ -f "RELEASE_NOTES.md" ]; then
99+ echo "notes<<EOF" >> $GITHUB_OUTPUT
100+ cat RELEASE_NOTES.md >> $GITHUB_OUTPUT
101+ echo "EOF" >> $GITHUB_OUTPUT
102+ else
103+ echo "notes=Release ${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT
104+ fi
105+
106+ - name : Create Release
107+ uses : softprops/action-gh-release@v2
108+ with :
109+ name : ${{ steps.version.outputs.version }}
110+ body : ${{ steps.release_notes.outputs.notes }}
111+ files : |
112+ artifacts/**/*.zip
113+ artifacts/**/*.tar.gz
114+ draft : false
115+ prerelease : ${{ contains(steps.version.outputs.version, '-') }}
116+ env :
117+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments