Skip to content

Merge pull request #9 from DevPossible:dev #8

Merge pull request #9 from DevPossible:dev

Merge pull request #9 from DevPossible:dev #8

Workflow file for this run

name: Publish Packages
on:
push:
branches: [ main ]
workflow_dispatch:
inputs:
version:
description: 'Version to publish (leave empty to use version.json)'
required: false
type: string
jobs:
read-version:
name: Read Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Get version from version.json
id: get-version
run: |
VERSION=$(jq -r '.library_version' version.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing library version: $VERSION"
publish-nuget:
name: Publish to NuGet
needs: read-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore src/CSharp/DevPossible.Ton/DevPossible.Ton.csproj
- name: Build
run: dotnet build src/CSharp/DevPossible.Ton/DevPossible.Ton.csproj --configuration Release --no-restore
- name: Test
run: dotnet test src/CSharp/DevPossible.Ton.Tests/DevPossible.Ton.Tests.csproj --configuration Release --verbosity normal
- name: Pack
run: dotnet pack src/CSharp/DevPossible.Ton/DevPossible.Ton.csproj --configuration Release --no-build -p:PackageVersion=${{ needs.read-version.outputs.version }} --output .
- name: Publish to NuGet
run: dotnet nuget push DevPossible.Ton.*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
publish-npm:
name: Publish to npm
needs: read-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Verify package.json version
working-directory: src/JavaScript/devpossible-ton
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
TARGET_VERSION="${{ needs.read-version.outputs.version }}"
echo "package.json version: $CURRENT_VERSION"
echo "version.json version: $TARGET_VERSION"
if [ "$CURRENT_VERSION" != "$TARGET_VERSION" ]; then
echo "❌ Version mismatch detected!"
echo "This should not happen - version-check.yml should have caught this."
exit 1
fi
- name: Install dependencies
working-directory: src/JavaScript/devpossible-ton
run: npm ci
- name: Build
working-directory: src/JavaScript/devpossible-ton
run: npm run build
- name: Test
working-directory: src/JavaScript/devpossible-ton
run: npm test
- name: Publish to npm
working-directory: src/JavaScript/devpossible-ton
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-pypi:
name: Publish to PyPI
needs: read-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Verify setup.py version
working-directory: src/Python/devpossible_ton
run: |
VERSION="${{ needs.read-version.outputs.version }}"
PYTHON_VERSION=$(echo $VERSION | sed 's/-alpha/a0/')
CURRENT_VERSION=$(grep 'version=' setup.py | sed -n 's/.*version="\([^"]*\)".*/\1/p')
echo "setup.py version: $CURRENT_VERSION"
echo "Expected version: $PYTHON_VERSION"
if [ "$CURRENT_VERSION" != "$PYTHON_VERSION" ]; then
echo "❌ Version mismatch detected!"
echo "This should not happen - version-check.yml should have caught this."
exit 1
fi
- name: Build package
working-directory: src/Python/devpossible_ton
run: python -m build
- name: Publish to PyPI
working-directory: src/Python/devpossible_ton
run: python -m twine upload dist/* --skip-existing
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
create-release:
name: Create GitHub Release
needs: [read-version, publish-nuget, publish-npm, publish-pypi]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.read-version.outputs.version }}
release_name: Release ${{ needs.read-version.outputs.version }}
body: |
Release ${{ needs.read-version.outputs.version }}
Published to:
- NuGet: https://www.nuget.org/packages/DevPossible.Ton/${{ needs.read-version.outputs.version }}
- npm: https://www.npmjs.com/package/@devpossible/ton/v/${{ needs.read-version.outputs.version }}
- PyPI: https://pypi.org/project/devpossible-ton/${{ needs.read-version.outputs.version }}/
draft: false
prerelease: ${{ contains(needs.read-version.outputs.version, 'alpha') || contains(needs.read-version.outputs.version, 'beta') }}