Skip to content

Fix a few bugs

Fix a few bugs #7

Workflow file for this run

name: CI and Release
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
branches:
- master
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Setup .NET 9
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: |
~/.nuget/packages
**/packages.config
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json', '**/packages.config') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Determine version
id: version
shell: bash
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG_NAME=${GITHUB_REF#refs/tags/}
TAG_NAME=${TAG_NAME#v}
VERSION="${TAG_NAME}.${GITHUB_RUN_NUMBER}"
else
VERSION="2.1.0.${GITHUB_RUN_NUMBER}"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Restore
run: dotnet restore CoreJ2K.sln
- name: Build
run: dotnet build CoreJ2K.sln -c Release --no-restore
- name: Pack
run: |
dotnet pack CoreJ2K.sln -c Release --no-build -o ./artifacts /p:Version=${{ steps.version.outputs.VERSION }} /p:PackageVersion=${{ steps.version.outputs.VERSION }} /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg
- name: Upload packages (artifact)
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: artifacts/*.nupkg
publish:
needs: build
runs-on: windows-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download packages
uses: actions/download-artifact@v4
with:
name: nuget-packages
- name: Push to NuGet.org
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
for pkg in $(ls artifacts/*.nupkg 2>/dev/null || true); do
dotnet nuget push "$pkg" -k "$NUGET_API_KEY" -s https://api.nuget.org/v3/index.json --skip-duplicate
done
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
body: Release ${{ steps.version.outputs.VERSION }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts
asset_name: corej2k-packages-${{ steps.version.outputs.VERSION }}.zip
asset_content_type: application/zip