Skip to content

Release (Test-Run: false) #8

Release (Test-Run: false)

Release (Test-Run: false) #8

Workflow file for this run

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
type: boolean
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 "(?<=<version>)[^<]+")
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 }}