|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + create_release: |
| 10 | + description: 'Create a GitHub release' |
| 11 | + required: false |
| 12 | + default: 'true' |
| 13 | + type: choice |
| 14 | + options: |
| 15 | + - 'true' |
| 16 | + - 'false' |
| 17 | + |
| 18 | +jobs: |
| 19 | + release: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v3 |
| 24 | + with: |
| 25 | + submodules: true |
| 26 | + fetch-depth: 0 |
| 27 | + |
| 28 | + - name: Set short sha |
| 29 | + id: info |
| 30 | + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT |
| 31 | + |
| 32 | + - uses: kzrnm/get-net-sdk-project-versions-action@v2 |
| 33 | + id: get-version |
| 34 | + with: |
| 35 | + proj-path: BepInEx.AutoPlugin/BepInEx.AutoPlugin.csproj |
| 36 | + |
| 37 | + - name: Setup .NET |
| 38 | + uses: actions/setup-dotnet@v4 |
| 39 | + with: |
| 40 | + dotnet-version: 9.x |
| 41 | + |
| 42 | + - name: Run the Cake script |
| 43 | + uses: cake-build/cake-action@v1 |
| 44 | + with: |
| 45 | + verbosity: Diagnostic |
| 46 | + |
| 47 | + - uses: actions/upload-artifact@v4 |
| 48 | + with: |
| 49 | + name: BepInEx.AutoPlugin-${{ steps.get-version.outputs.version }}-${{ steps.info.outputs.sha_short }} |
| 50 | + path: | |
| 51 | + artifacts/package/release/*.nupkg |
| 52 | + artifacts/bin/BepInEx.AutoPlugin/release/BepInEx.AutoPlugin.dll |
| 53 | +
|
| 54 | + - name: Create Git Tag (if needed) |
| 55 | + if: ${{ github.event_name == 'workflow_dispatch' }} |
| 56 | + run: | |
| 57 | + TAG_NAME="${{ steps.get-version.outputs.version }}" |
| 58 | + # Check if tag already exists |
| 59 | + if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then |
| 60 | + echo "Tag $TAG_NAME already exists" |
| 61 | + else |
| 62 | + echo "Creating tag $TAG_NAME" |
| 63 | + git config user.name github-actions |
| 64 | + git config user.email github-actions@github.com |
| 65 | + git tag -a "$TAG_NAME" -m "Release $TAG_NAME" |
| 66 | + git push origin "$TAG_NAME" |
| 67 | + fi |
| 68 | +
|
| 69 | + - name: Push NuGet package |
| 70 | + run: | |
| 71 | + dotnet nuget push artifacts/package/release/*.nupkg --source ${{ secrets.NUGET_SOURCE }} --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate |
| 72 | +
|
| 73 | + - name: Create GitHub Release |
| 74 | + if: ${{ (github.ref_type == 'tag') || (github.event_name == 'workflow_dispatch' && github.event.inputs.create_release == 'true') }} |
| 75 | + uses: softprops/action-gh-release@v2 |
| 76 | + with: |
| 77 | + draft: true |
| 78 | + prerelease: false |
| 79 | + generate_release_notes: false |
| 80 | + name: ${{ steps.get-version.outputs.version }} |
| 81 | + tag_name: ${{ steps.get-version.outputs.version }} |
| 82 | + target_commitish: ${{ github.sha }} |
| 83 | + files: | |
| 84 | + ./artifacts/package/release/*.nupkg |
| 85 | + ./artifacts/bin/BepInEx.AutoPlugin/release/BepInEx.AutoPlugin.dll |
| 86 | + env: |
| 87 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments