Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/build-csharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
- "src/csharp/**"
- "PyMCU.SDK.slnx"
- ".github/workflows/build-csharp.yml"
tags:
- "v*"
pull_request:
branches: [main]
paths:
Expand All @@ -18,6 +20,8 @@ jobs:
build:
name: Build & pack NuGet
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout
Expand Down Expand Up @@ -49,3 +53,68 @@ jobs:
if-no-files-found: error
retention-days: 30

publish-private:
name: Publish to private NuGet feed
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref_type == 'branch'
permissions:
contents: read

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: PyMCU.Backend.SDK-nupkg
path: artifacts/

- name: Connect to headscale network
uses: tailscale/github-action@v3
with:
authkey: ${{ secrets.HEADSCALE_AUTH_KEY }}
login-server: ${{ secrets.HEADSCALE_URL }}

- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"

- name: Publish to private NuGet feed
env:
PRIVATE_NUGET_URL: ${{ secrets.PRIVATE_NUGET_URL }}
PRIVATE_NUGET_API_KEY: ${{ secrets.PRIVATE_NUGET_API_KEY }}
run: |
dotnet nuget push artifacts/*.nupkg \
--source "$PRIVATE_NUGET_URL" \
--api-key "$PRIVATE_NUGET_API_KEY" \
--skip-duplicate

publish-public:
name: Publish to NuGet.org
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref_type == 'tag'
environment: nuget
permissions:
contents: read

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: PyMCU.Backend.SDK-nupkg
path: artifacts/

- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"

- name: Publish to NuGet.org
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
dotnet nuget push artifacts/*.nupkg \
--source https://api.nuget.org/v3/index.json \
--api-key "$NUGET_API_KEY" \
--skip-duplicate
61 changes: 60 additions & 1 deletion .github/workflows/build-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ on:
- "src/python/**"
- "pyproject.toml"
- ".github/workflows/build-python.yml"
tags:
- "v*"
pull_request:
branches: [main]
paths:
- "src/python/**"
- "pyproject.toml"
- ".github/workflows/build-python.yml"

jobs:
build:
name: Build wheel & sdist
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -24,7 +29,7 @@ jobs:
with:
python-version: "3.11"
- name: Install Hatch
run: pip install "hatch>=1.25.0"
run: pip install "hatch>=1.0.0"
- name: Build
run: hatch build
- name: Upload artifacts
Expand All @@ -34,3 +39,57 @@ jobs:
path: dist/
if-no-files-found: error
retention-days: 30

publish-private:
name: Publish to private PyPI
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref_type == 'branch'
permissions:
contents: read
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: pymcu-plugin-sdk-dist
path: dist/

- name: Connect to headscale network
uses: tailscale/github-action@v3
with:
authkey: ${{ secrets.HEADSCALE_AUTH_KEY }}
login-server: ${{ secrets.HEADSCALE_URL }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Twine
run: pip install twine

- name: Publish to private registry
env:
TWINE_REPOSITORY_URL: ${{ secrets.PRIVATE_PYPI_URL }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PRIVATE_PYPI_TOKEN }}
run: twine upload dist/*

publish-public:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref_type == 'tag'
environment: pypi
permissions:
contents: read
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: pymcu-plugin-sdk-dist
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Loading