|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: windows-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Setup .NET |
| 19 | + uses: actions/setup-dotnet@v4 |
| 20 | + with: |
| 21 | + dotnet-version: '8.0.x' |
| 22 | + |
| 23 | + - name: Get version from tag |
| 24 | + id: version |
| 25 | + shell: pwsh |
| 26 | + run: | |
| 27 | + $tag = $env:GITHUB_REF -replace 'refs/tags/','' |
| 28 | + if ($tag -notmatch '^v\d+\.\d+\.\d+$') { |
| 29 | + throw "Tag must be in format v1.2.3" |
| 30 | + } |
| 31 | + $version = $tag -replace '^v','' |
| 32 | + $assemblyVersion = "$version.0" |
| 33 | + echo "VERSION=$version" >> $env:GITHUB_OUTPUT |
| 34 | + echo "ASSEMBLY_VERSION=$assemblyVersion" >> $env:GITHUB_OUTPUT |
| 35 | +
|
| 36 | + - name: Build and publish x64 |
| 37 | + run: | |
| 38 | + dotnet publish src/App/App.csproj -c Release -r win-x64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/x64 |
| 39 | + dotnet publish src/Vpn.Service/Vpn.Service.csproj -c Release -r win-x64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/x64 |
| 40 | +
|
| 41 | + - name: Build and publish arm64 |
| 42 | + run: | |
| 43 | + dotnet publish src/App/App.csproj -c Release -r win-arm64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/arm64 |
| 44 | + dotnet publish src/Vpn.Service/Vpn.Service.csproj -c Release -r win-arm64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/arm64 |
| 45 | +
|
| 46 | + - name: Create ZIP archives |
| 47 | + shell: pwsh |
| 48 | + run: | |
| 49 | + Compress-Archive -Path "publish/x64/*" -DestinationPath "./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-x64.zip" |
| 50 | + Compress-Archive -Path "publish/arm64/*" -DestinationPath "./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-arm64.zip" |
| 51 | +
|
| 52 | + - name: Create Release |
| 53 | + uses: softprops/action-gh-release@v1 |
| 54 | + with: |
| 55 | + files: | |
| 56 | + ./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-x64.zip |
| 57 | + ./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-arm64.zip |
| 58 | + name: Release ${{ steps.version.outputs.VERSION }} |
| 59 | + generate_release_notes: true |
| 60 | + env: |
| 61 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments