Add GitHub Actions workflows for build and release processes #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | ||
|
Check failure on line 1 in .github/workflows/release.yml
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
| workflow_dispatch: | ||
| jobs: | ||
| release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| fetch-depth: 0 # Need to fetch all for proper history | ||
| - name: Collect build info | ||
| id: info | ||
| uses: actions/github-script@v6 | ||
| with: | ||
| script: | | ||
| let shortHash = ""; | ||
| await exec.exec("git", ["rev-parse", "--short", "HEAD"], { | ||
| listeners: { | ||
| stdout: d => shortHash += d.toString().trim(), | ||
| } | ||
| }); | ||
| core.setOutput("sha_short", shortHash); | ||
| // Get version from tag if available | ||
| let version = ""; | ||
| if (context.ref.startsWith("refs/tags/")) { | ||
| version = context.ref.replace("refs/tags/", ""); | ||
| if (version.startsWith("v")) { | ||
| version = version.substring(1); | ||
| } | ||
| } | ||
| core.setOutput("version", version); | ||
| - uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: "9.0.x" | ||
| - name: Build | ||
| run: | | ||
| dotnet build -c Release | ||
| dotnet pack -c Release --no-build -o ./bin/dist | ||
| - name: Publish to GitHub Packages | ||
| run: | | ||
| dotnet nuget push ./bin/dist/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://nuget-modding.resonite.net/v3/index.json --skip-duplicate | ||
| - name: Create GitHub Release | ||
| if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| draft: true | ||
| prerelease: false | ||
| generate_release_notes: false | ||
| name: v${{ needs.build.outputs.version }} | ||
| tag_name: v${{ needs.build.outputs.version }} | ||
| target_commitish: ${{ github.sha }} | ||
| files: ./bin/dist/*.nupkg | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||