diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml new file mode 100644 index 0000000..f9f42e3 --- /dev/null +++ b/.github/workflows/nuget.yml @@ -0,0 +1,50 @@ +name: Publish NuGet + +on: + workflow_dispatch: + inputs: + version: + description: 'Version number' + required: true + +jobs: + build: + runs-on: ubuntu-latest + env: + PROJECT_FILE: src/FSharp.Finance.Personal.fsproj + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + + - name: Get current version + id: get_version + run: | + CURRENT_VERSION=$(grep -oP '(?<=)[^<]+' ${{ env.PROJECT_FILE }}) + echo "Current version is $CURRENT_VERSION" + echo "::set-output name=current_version::$CURRENT_VERSION" + + - name: Update version number + run: | + VERSION=${{ github.event.inputs.version }} + echo "Updating version to $VERSION" + sed -i "s/[0-9]\+\.[0-9]\+\.[0-9]\+<\/Version>/$VERSION<\/Version>/" ${{ env.PROJECT_FILE }} + + - name: Build + run: dotnet build -c Release + + - name: Pack + run: dotnet pack -c Release --no-build --output . + + # - name: Publish NuGet package + # run: dotnet nuget push *.nupkg --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json + + - name: Create Git tag + run: | + git config --global user.name 'github-actions' + git config --global user.email 'github-actions@github.com' + git tag $VERSION + git push origin $VERSION