Release ValidationPackage.Model #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Release ValidationPackage.Model" | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: release-validationpackage-model | |
| cancel-in-progress: false | |
| jobs: | |
| verify-and-pack: | |
| name: "Verify and pack Model" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up portable package toolchain | |
| uses: ./.github/actions/setup-portable | |
| - name: Run solution tests | |
| run: ./build.sh TestSolution | |
| - name: Test packed Model packages | |
| run: ./build.sh TestPortableModel | |
| - name: Preserve release artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: validationpackage-model-release | |
| path: | | |
| artifacts/packages/ValidationPackage.Model.*.nupkg | |
| artifacts/packages/nfdi4plants-validationpackage-model-*.tgz | |
| artifacts/packages/validationpackage_model-*.whl | |
| artifacts/portable/validationpackage-model/javascript/package.json | |
| if-no-files-found: error | |
| retention-days: 7 | |
| overwrite: true | |
| publish-nuget: | |
| name: "Publish Model to NuGet" | |
| needs: verify-and-pack | |
| runs-on: ubuntu-latest | |
| environment: release | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Set up .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.x.x | |
| - name: Download release artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: validationpackage-model-release | |
| path: artifacts | |
| - name: NuGet login | |
| uses: NuGet/login@v1 | |
| id: nuget-login | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - name: Publish Model to NuGet | |
| run: dotnet nuget push ./artifacts/packages/ValidationPackage.Model.*.nupkg --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| publish-npm: | |
| name: "Publish Model to npm" | |
| needs: verify-and-pack | |
| runs-on: ubuntu-latest | |
| environment: release | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| - name: Install npm with trusted-publishing support | |
| run: npm install --global npm@11.5.1 | |
| - name: Download release artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: validationpackage-model-release | |
| path: artifacts | |
| - name: Publish Model to npm | |
| shell: bash | |
| run: | | |
| shopt -s nullglob | |
| packages=(artifacts/packages/nfdi4plants-validationpackage-model-*.tgz) | |
| if [[ ${#packages[@]} -ne 1 ]]; then | |
| echo "Expected exactly one Model npm package, found ${#packages[@]}." >&2 | |
| exit 1 | |
| fi | |
| manifest=artifacts/portable/validationpackage-model/javascript/package.json | |
| package_name="$(node -p "require('./$manifest').name")" | |
| package_version="$(node -p "require('./$manifest').version")" | |
| if npm view "${package_name}@${package_version}" version >/dev/null 2>&1; then | |
| echo "${package_name}@${package_version} is already published; skipping." | |
| else | |
| npm publish "${packages[0]}" --access public | |
| fi | |
| publish-pypi: | |
| name: "Publish Model to PyPI" | |
| needs: verify-and-pack | |
| runs-on: ubuntu-latest | |
| environment: release | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Download release artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: validationpackage-model-release | |
| path: artifacts | |
| - name: Stage Model wheel | |
| shell: bash | |
| run: | | |
| shopt -s nullglob | |
| packages=(artifacts/packages/validationpackage_model-*.whl) | |
| if [[ ${#packages[@]} -ne 1 ]]; then | |
| echo "Expected exactly one Model wheel, found ${#packages[@]}." >&2 | |
| exit 1 | |
| fi | |
| mkdir -p artifacts/pypi | |
| cp "${packages[0]}" artifacts/pypi/ | |
| - name: Publish Model to PyPI | |
| uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 | |
| with: | |
| packages-dir: artifacts/pypi | |
| skip-existing: true |