Publish #20
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
| # This workflow will build a .NET project | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
| name: Publish | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| prerelease: | |
| default: true | |
| type: boolean | |
| required: true | |
| description: Set as pre-release | |
| push: | |
| default: false | |
| type: boolean | |
| description: Push to nuget.org | |
| push: | |
| branches: ["master"] | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| env: | |
| PackageOutputDir: ".packages" | |
| Prerelease: ${{ github.event.inputs.prerelease || 'false' }} | |
| PushPackage: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event.inputs.push }} | |
| NpmTokenExists: ${{ secrets.NPM_TOKEN != '' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/[email protected] | |
| with: | |
| versionSpec: "6.0.5" | |
| - name: Determine Version | |
| run: | | |
| ${GITVERSION_PATH}/dotnet-gitversion /output buildserver /output json | |
| - name: Pack Nuget | |
| run: | | |
| dotnet pack --nologo -o ${PackageOutputDir} \ | |
| -p:PackageVersion=${GitVersion_SemVer} \ | |
| -p:FileVersion=${GitVersion_MajorMinorPatch} \ | |
| -p:AssemblyVersion=${GitVersion_AssemblySemVer} \ | |
| -p:FileVersion=${GitVersion_MajorMinorPatch} \ | |
| -p:Configuration=Release | |
| - name: Pack Npm | |
| run: | | |
| ROOT=$(pwd) | |
| cd src/ApiCodeGenerator.Npm | |
| npm version ${GitVersion_FullSemVer} --no-git-tag-version | |
| npm run pack-ci -- ${ROOT}/${PackageOutputDir} | |
| - name: Nuget Push | |
| if: env.PushPackage == 'true' | |
| working-directory: ${{ env.PackageOutputDir }} | |
| run: dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} | |
| - name: Npm Push | |
| if: env.PushPackage == 'true' && env.NpmTokenExists == 'true' | |
| uses: JS-DevTools/npm-publish@v4 | |
| with: | |
| token: ${{ secrets.NPM_TOKEN }} | |
| package: ${{ env.PackageOutputDir }} | |
| - name: Create Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| name: v${{ env.GitVersion_SemVer }} | |
| tag: v${{ env.GitVersion_SemVer }} | |
| artifacts: ${{ env.PackageOutputDir }}/*.nupkg,${{ env.PackageOutputDir }}/*.tgz | |
| generateReleaseNotes: true | |
| commit: ${{ env.GitVersion_Sha}} | |
| prerelease: ${{ env.Prerelease }} |