v1.0.4 #1
Workflow file for this run
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: Publish NuGet Package | |
| on: | |
| release: | |
| types: | |
| - published | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Resolve package version | |
| id: version | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.event_name }}" == "release" ]]; then | |
| TAG_NAME="${{ github.event.release.tag_name }}" | |
| elif [[ "${{ github.ref_type }}" == "tag" ]]; then | |
| TAG_NAME="${{ github.ref_name }}" | |
| else | |
| echo "workflow_dispatch must be run from a tag ref such as v1.0.4." >&2 | |
| exit 1 | |
| fi | |
| PACKAGE_VERSION="${TAG_NAME#v}" | |
| if [[ -z "${PACKAGE_VERSION}" ]]; then | |
| echo "Package version could not be resolved from the release tag." >&2 | |
| exit 1 | |
| fi | |
| echo "tag_name=${TAG_NAME}" >> "${GITHUB_OUTPUT}" | |
| echo "package_version=${PACKAGE_VERSION}" >> "${GITHUB_OUTPUT}" | |
| - name: Restore | |
| run: dotnet restore YCode.CLI/YCode.CLI.csproj | |
| - name: Pack | |
| run: > | |
| dotnet pack YCode.CLI/YCode.CLI.csproj | |
| --configuration Release | |
| --no-restore | |
| -p:ContinuousIntegrationBuild=true | |
| -p:PackageVersion=${{ steps.version.outputs.package_version }} | |
| --output ${{ github.workspace }}/artifacts | |
| - name: Publish to NuGet.org | |
| shell: bash | |
| run: | | |
| shopt -s nullglob | |
| packages=("${{ github.workspace }}/artifacts/"*.nupkg) | |
| if (( ${#packages[@]} == 0 )); then | |
| echo "No .nupkg files were generated." >&2 | |
| exit 1 | |
| fi | |
| dotnet nuget push "${packages[@]}" \ | |
| --api-key "${{ secrets.NUGET_API_KEY }}" \ | |
| --source "https://api.nuget.org/v3/index.json" \ | |
| --skip-duplicate | |
| - name: Configure GitHub Packages source | |
| run: > | |
| dotnet nuget add source | |
| --username "${{ github.repository_owner }}" | |
| --password "${{ secrets.GITHUB_TOKEN }}" | |
| --store-password-in-clear-text | |
| --name github | |
| "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" | |
| - name: Publish to GitHub Packages | |
| shell: bash | |
| run: | | |
| shopt -s nullglob | |
| packages=("${{ github.workspace }}/artifacts/"*.nupkg) | |
| dotnet nuget push "${packages[@]}" \ | |
| --source github \ | |
| --api-key "${{ secrets.GITHUB_TOKEN }}" \ | |
| --skip-duplicate | |
| - name: Upload package to GitHub Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| shell: bash | |
| run: | | |
| shopt -s nullglob | |
| packages=("${{ github.workspace }}/artifacts/"*.nupkg) | |
| gh release upload "${{ steps.version.outputs.tag_name }}" "${packages[@]}" --clobber |