44 workflow_dispatch :
55 inputs :
66 version :
7- description : ' Version'
7+ description : " Version"
88 required : true
99
1010permissions :
1111 contents : write
12-
12+
1313jobs :
1414 build :
1515 uses : ./.github/workflows/build.yml
16-
16+
1717 publish :
1818 needs : build
1919 runs-on : ${{matrix.os}}
2020
2121 strategy :
22- matrix :
23- include :
24- - os : ubuntu-latest
25- target : linux-x64
26- id : linux-amd64
27- - os : ubuntu-latest
28- target : linux-musl-x64
29- id : linux-alpine-amd64
30- - os : ubuntu-24.04-arm
31- target : linux-arm64
32- id : linux-arm64
33- - os : ubuntu-24.04-arm
34- target : linux-musl-arm64
35- id : linux-alpine-arm64
36- - os : windows-latest
37- target : win-x64
38- id : windows-amd64
39- - os : windows-latest
40- target : win-x86
41- id : windows-x86
42- - os : windows-11-arm
43- target : win-arm64
44- id : windows-arm64
45-
22+ matrix :
23+ include :
24+ - os : ubuntu-latest
25+ target : linux-x64
26+ id : linux-amd64
27+ - os : ubuntu-latest
28+ target : linux-musl-x64
29+ id : linux-alpine-amd64
30+ - os : ubuntu-24.04-arm
31+ target : linux-arm64
32+ id : linux-arm64
33+ - os : ubuntu-24.04-arm
34+ target : linux-musl-arm64
35+ id : linux-alpine-arm64
36+ - os : windows-latest
37+ target : win-x64
38+ id : windows-amd64
39+ - os : windows-latest
40+ target : win-x86
41+ id : windows-x86
42+ - os : windows-11-arm
43+ target : win-arm64
44+ id : windows-arm64
45+
4646 steps :
47- - uses : actions/checkout@v4
48- - name : Setup .NET
49- uses : actions/setup-dotnet@v4
50- with :
51- dotnet-version : 9.0.x
52-
53- - name : Restore dependencies
54- run : dotnet restore
55- - name : Build
56- run : dotnet build --no-restore
57- - name : Publish
58- run : dotnet publish -c Release -r ${{matrix.target}} -o ${{github.workspace}}/publish/${{matrix.target}} -p:Version=${{inputs.version}}
59- - name : Compress (Ubuntu)
60- if : startsWith(matrix.os, 'ubuntu')
61- run : |
62- mkdir -p ${{github.workspace}}/artifacts
63- cd ${{github.workspace}}/publish/${{matrix.target}}
64- mv LineCount loc
65- tar -cjf ${{github.workspace}}/artifacts/loc-v${{inputs.version}}-${{matrix.id}}.tar.xz loc
66- tar -czf ${{github.workspace}}/artifacts/loc-v${{inputs.version}}-${{matrix.id}}.tar.gz loc
67- - name : Compress (Windows)
68- if : startsWith(matrix.os, 'windows')
69- shell : pwsh
70- run : |
71- New-Item -Type Directory -Path ${{github.workspace}}/artifacts -Force
72- cd ${{github.workspace}}/publish/${{matrix.target}}
73- Rename-Item -Path LineCount.exe -NewName loc.exe
74- Compress-Archive -LiteralPath loc.exe -DestinationPath ${{github.workspace}}/artifacts/loc-v${{inputs.version}}-${{matrix.id}}.zip
75- - name : Upload Artifact
76- uses : actions/upload-artifact@v4
77- with :
78- name : loc-${{matrix.target}}
79- path : ${{github.workspace}}/artifacts/*
47+ - uses : actions/checkout@v4
48+ - name : Setup .NET
49+ uses : actions/setup-dotnet@v4
50+ with :
51+ dotnet-version : 9.0.x
52+
53+ - name : Restore dependencies
54+ run : dotnet restore
55+ - name : Build
56+ run : dotnet build --no-restore
57+ - name : Publish
58+ run : dotnet publish -c Release -r ${{matrix.target}} -o ${{github.workspace}}/publish/${{matrix.target}} -p:Version=${{inputs.version}}
59+ - name : Compress (Ubuntu)
60+ if : startsWith(matrix.os, 'ubuntu')
61+ run : |
62+ mkdir -p ${{github.workspace}}/artifacts
63+ cd ${{github.workspace}}/publish/${{matrix.target}}
64+ mv LineCount loc
65+ tar -cjf ${{github.workspace}}/artifacts/loc-v${{inputs.version}}-${{matrix.id}}.tar.xz loc
66+ tar -czf ${{github.workspace}}/artifacts/loc-v${{inputs.version}}-${{matrix.id}}.tar.gz loc
67+ - name : Compress (Windows)
68+ if : startsWith(matrix.os, 'windows')
69+ shell : pwsh
70+ run : |
71+ New-Item -Type Directory -Path ${{github.workspace}}/artifacts -Force
72+ cd ${{github.workspace}}/publish/${{matrix.target}}
73+ Rename-Item -Path LineCount.exe -NewName loc.exe
74+ Compress-Archive -LiteralPath loc.exe -DestinationPath ${{github.workspace}}/artifacts/loc-v${{inputs.version}}-${{matrix.id}}.zip
75+ - name : Upload Artifact
76+ uses : actions/upload-artifact@v4
77+ with :
78+ name : loc-${{matrix.target}}
79+ path : ${{github.workspace}}/artifacts/*
8080
8181 release :
8282 needs : publish
8383
8484 runs-on : ubuntu-latest
8585
8686 steps :
87- - uses : actions/checkout@v4
88- - name : Download Artifacts
89- uses : actions/download-artifact@v4
90- with :
91- path : binaries
92- pattern : loc-*
93- merge-multiple : true
94- - name : Create Tag
95- run : |
96- git config --global user.name "github-actions[bot]"
97- git config --global user.email "github-actions[bot]@user.noreply.github.com"
98- sed -i 's/0.0.0/${{inputs.version}}/g' ${{github.workspace}}/src/LineCount.csproj
99- sed -i 's@<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>@<IncludeSourceRevisionInInformationalVersion>true</IncludeSourceRevisionInInformationalVersion>@g' ${{github.workspace}}/src/LineCount.csproj
100- git commit -am"temporary changes made for tag v${{inputs.version}}"
101- git tag -a "v${{inputs.version}}" -m"v${{inputs.version}}"
102- git reset --hard HEAD~1
103- git push origin "v${{inputs.version}}" --force-with-lease
104- env :
87+ - uses : actions/checkout@v4
88+ - name : Download Artifacts
89+ uses : actions/download-artifact@v4
90+ with :
91+ path : binaries
92+ pattern : loc-*
93+ merge-multiple : true
94+ - name : Create Tag
95+ run : |
96+ git config --global user.name "github-actions[bot]"
97+ git config --global user.email "github-actions[bot]@user.noreply.github.com"
98+ sed -i 's/0.0.0/${{inputs.version}}/g' ${{github.workspace}}/src/LineCount.csproj
99+ sed -i 's@<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>@<IncludeSourceRevisionInInformationalVersion>true</IncludeSourceRevisionInInformationalVersion>@g' ${{github.workspace}}/src/LineCount.csproj
100+ git commit -am"temporary changes made for tag v${{inputs.version}}"
101+ git tag -a "v${{inputs.version}}" -m"v${{inputs.version}}"
102+ git reset --hard HEAD~1
103+ git push origin "v${{inputs.version}}" --force-with-lease
104+ env :
105+ GH_TOKEN : ${{secrets.GITHUB_TOKEN}}
106+ - name : Prepare Installation Script (Windows)
107+ run : |
108+ mkdir -p installers
109+ cp ${{github.workspace}}/packaging/windows/script/install.ps1 installers/install.ps1
110+ sed -i 's/__VERSION__/v${{inputs.version}}/g' installers/install.ps1
111+ - name : Prepare Installation Script (Windows)
112+ run : |
113+ cp ${{github.workspace}}/packaging/linux/script/install.sh installers/install.sh
114+ sed -i 's/__VERSION__/v${{inputs.version}}/g' installers/install.sh
115+ chmod +x installers/install.sh
116+ - name : Create Release
117+ run : >
118+ gh release create "v${{inputs.version}}"
119+ --prerelease=${{ contains(inputs.version, '-') || startsWith(inputs.version, '0') }}
120+ --title "v${{inputs.version}}"
121+ --notes "https://github.com/draconware-dev/LineCount/blob/main/Changelog.md"
122+ binaries/* installers/*
123+ env :
105124 GH_TOKEN : ${{secrets.GITHUB_TOKEN}}
106- - name : Prepare Installation Script (Windows)
107- run : |
108- mkdir -p installers
109- cp ${{github.workspace}}/packaging/windows/script/install.ps1 installers/install.ps1
110- sed -i 's/__VERSION__/v${{inputs.version}}/g' installers/install.ps1
111- - name : Prepare Installation Script (Windows)
112- run : |
113- cp ${{github.workspace}}/packaging/linux/script/install.sh installers/install.sh
114- sed -i 's/__VERSION__/v${{inputs.version}}/g' installers/install.sh
115- chmod +x installers/install.sh
116- - name : Create Release
117- run : >
118- gh release create "v${{inputs.version}}"
119- --prerelease=${{ contains(inputs.version, '-') || startsWith(inputs.version, '0') }}
120- --title "v${{inputs.version}}"
121- --notes "https://github.com/draconware-dev/LineCount/blob/main/Changelog.md"
122- binaries/* installers/*
123- env :
124- GH_TOKEN : ${{secrets.GITHUB_TOKEN}}
0 commit comments