diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 409c3d3..a101665 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,15 +8,7 @@ on: branches: [ "main" ] pull_request: branches: [ "main" ] - workflow_dispatch: - # used for [release](https://github.com/bytecodealliance/componentize-dotnet/blob/main/RELEASE.md) - branches: [ "main" ] - inputs: - test-run: - description: 'DryRun: Run the workflow without publishing step' - default: 'true' - required: false - + workflow_call: jobs: build: @@ -48,46 +40,3 @@ jobs: path: artifacts/*.nupkg if-no-files-found: error if: ${{ matrix.dotnet == '8.x' }} # only need one package published https://github.com/actions/upload-artifact?tab=readme-ov-file#not-uploading-to-the-same-artifact - - release: - runs-on: ubuntu-latest - needs: build - permissions: - contents: write - name: Release - if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' - steps: - - uses: actions/checkout@v4 # needed for the create release step - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.x - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - name: nuget-packages - - name: Extract nuget version - id: extract_version - run: | - ls *.nupkg - version=$(unzip -p ./*SDK*.nupkg '*.nuspec' | grep -oPm1 "(?<=)[^<]+") - echo "Version: $version" - echo "version=$version" >> $GITHUB_OUTPUT - # Publish to https://nuget.org and tag the version on repo if test-run=false - - name: Publish - run: dotnet nuget push ./*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} - if: ${{ !inputs.test-run }} - - name: Push version tag - if: ${{ !inputs.test-run }} - env: - TAG: v${{ steps.extract_version.outputs.version }} - run: | - git tag $TAG - git push origin $TAG - - name: Create release - if: ${{ !inputs.test-run }} - run: | - gh release create $TAG --generate-notes --prerelease - env: - GH_TOKEN: ${{ github.token }} - TAG: v${{ steps.extract_version.outputs.version }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ed8f644 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,59 @@ +name: Release +run-name: "Release (Test-Run: ${{ inputs.test-run }})" + +on: + workflow_dispatch: + # used for [release](https://github.com/bytecodealliance/componentize-dotnet/blob/main/RELEASE.md) + branches: [ "main" ] + inputs: + test-run: + description: 'DryRun: Run the workflow without publishing step' + default: 'true' + required: false + +jobs: + build: + uses: ./.github/workflows/build.yml + + release: + runs-on: ubuntu-latest + needs: build + permissions: + contents: write + name: Release + if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v4 # needed for the create release step + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: nuget-packages + - name: Extract nuget version + id: extract_version + run: | + ls *.nupkg + version=$(unzip -p ./*SDK*.nupkg '*.nuspec' | grep -oPm1 "(?<=)[^<]+") + echo "Version: $version" + echo "version=$version" >> $GITHUB_OUTPUT + # Publish to https://nuget.org and tag the version on repo if test-run=false + - name: Publish + run: dotnet nuget push ./*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} + if: ${{ !inputs.test-run }} + - name: Push version tag + if: ${{ !inputs.test-run }} + env: + TAG: v${{ steps.extract_version.outputs.version }} + run: | + git tag $TAG + git push origin $TAG + - name: Create release + if: ${{ !inputs.test-run }} + run: | + gh release create $TAG --generate-notes --prerelease + env: + GH_TOKEN: ${{ github.token }} + TAG: v${{ steps.extract_version.outputs.version }}