patch #78
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: patch | |
| on: | |
| schedule: | |
| - cron: "0 13 * * 1" | |
| workflow_dispatch: | |
| jobs: | |
| setup-outputs: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| currentTag: ${{ steps.step1.outputs.currentTag }} | |
| commitCount: ${{ steps.step2.outputs.commitCount }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - id: step1 | |
| run: echo "currentTag=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_OUTPUT | |
| - id: step2 | |
| run: echo "commitCount=`echo $(git rev-list --count ${{steps.step1.outputs.currentTag}}..master)`" >> $GITHUB_OUTPUT | |
| - name: Outputs | |
| run: | | |
| echo "currentTag: ${{steps.step1.outputs.currentTag}}" | |
| echo "commitCount: ${{steps.step2.outputs.commitCount}}" | |
| make-patch: | |
| permissions: | |
| contents: write | |
| needs: setup-outputs | |
| runs-on: ubuntu-latest | |
| if: ${{needs.setup-outputs.outputs.commitCount >= 5}} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - id: step1 | |
| run: echo "newTag=`echo $(echo ${{needs.setup-outputs.outputs.currentTag}} | awk 'BEGIN{FS=OFS="."} {$3+=1} 1')`" >> $GITHUB_ENV | |
| - name: Edit csproj | |
| run: sed -i 's+<VersionPrefix>${{needs.setup-outputs.outputs.currentTag}}</VersionPrefix>+<VersionPrefix>${{env.newTag}}</VersionPrefix>+g' ./CSharpToJavaScript.csproj | |
| - uses: actions4git/setup-git@v1 | |
| - run: | | |
| git commit -am "Nuget ${{env.newTag}}" | |
| git push | |
| - run: git log ${{needs.setup-outputs.outputs.currentTag}}..master --format=format:'- [%s](https://github.com/TiLied/CSharpToJavaScript/commit/%H)%n' --output=./release.txt | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ env.newTag }} | |
| body_path: ./release.txt | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| - name: Update .csproj | |
| #TODO? I don't know how to cat a file and paste... | |
| #- run: | | |
| # file=$(cat ./release.txt) | |
| # echo "releaseNotes=$file" >> $GITHUB_ENV | |
| run: sed -i 's+<PackageReleaseNotes></PackageReleaseNotes>+<PackageReleaseNotes>https://github.com/TiLied/CSharpToJavaScript/releases/tag/${{env.newTag}}</PackageReleaseNotes>+g' ./CSharpToJavaScript.csproj | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Generate NuGet package | |
| run: dotnet pack --configuration Release --output ./packages | |
| - name: Publish NuGet package | |
| run: dotnet nuget push ./packages/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | |
| - run: cat ./CSharpToJavaScript.csproj | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: CSharpToJavaScript-${{ env.newTag }} | |
| path: ./packages | |
| - name: Environments | |
| run: | | |
| echo $newTag |