feat: Advanced marketplace features (marketplace-02) - dependency res… #5
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
| # Publish module tarball and checksum when a release tag is pushed. | ||
|
Check failure on line 1 in .github/workflows/publish-modules.yml
|
||
| # Tag format: {module-name}-v{version} (e.g. module-registry-v0.1.3, backlog-v0.29.0) | ||
| # | ||
| # Optional signing: set repository secrets SPECFACT_MODULE_PRIVATE_SIGN_KEY (PEM string) | ||
| # and SPECFACT_MODULE_PRIVATE_SIGN_KEY_PASSPHRASE to sign the module manifest before packaging. | ||
| name: Publish Modules | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| module_path: | ||
| description: "Path to module directory (e.g. src/specfact_cli/modules/module_registry)" | ||
| required: true | ||
| push: | ||
| tags: | ||
| - "*-v*" | ||
| jobs: | ||
| publish: | ||
| name: Validate and package module | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| env: | ||
| SPECFACT_MODULE_PRIVATE_SIGN_KEY: ${{ secrets.SPECFACT_MODULE_PRIVATE_SIGN_KEY }} | ||
| SPECFACT_MODULE_PRIVATE_SIGN_KEY_PASSPHRASE: ${{ secrets.SPECFACT_MODULE_PRIVATE_SIGN_KEY_PASSPHRASE }} | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install pyyaml beartype icontract cryptography cffi | ||
| - name: Resolve module path from tag | ||
| id: resolve | ||
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | ||
| run: | | ||
| TAG="${GITHUB_REF#refs/tags/}" | ||
| NAME="${TAG%-v*}" | ||
| VERSION="${TAG#*-v}" | ||
| echo "module_name=${NAME}" >> "$GITHUB_OUTPUT" | ||
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | ||
| NAME_NORM=$(echo "$NAME" | tr '-' '_') | ||
| if [ -d "src/specfact_cli/modules/${NAME_NORM}" ]; then | ||
| echo "module_path=src/specfact_cli/modules/${NAME_NORM}" >> "$GITHUB_OUTPUT" | ||
| elif [ -d "modules/${NAME}" ]; then | ||
| echo "module_path=modules/${NAME}" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "module_path=src/specfact_cli/modules/${NAME_NORM}" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| - name: Resolve module path (manual) | ||
| id: resolve_manual | ||
| if: github.event_name == 'workflow_dispatch' | ||
| run: | | ||
| echo "module_path=${{ github.event.inputs.module_path }}" >> "$GITHUB_OUTPUT" | ||
| - name: Sign module manifest (optional) | ||
| if: secrets.SPECFACT_MODULE_PRIVATE_SIGN_KEY != "" | ||
| run: | | ||
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | ||
| MODULE_PATH="${{ github.event.inputs.module_path }}" | ||
| else | ||
| MODULE_PATH="${{ steps.resolve.outputs.module_path }}" | ||
| fi | ||
| MANIFEST="${MODULE_PATH}/module-package.yaml" | ||
| if [ -f "$MANIFEST" ]; then | ||
| python scripts/sign-modules.py "$MANIFEST" | ||
| fi | ||
| - name: Publish module | ||
| run: | | ||
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | ||
| MODULE_PATH="${{ github.event.inputs.module_path }}" | ||
| else | ||
| MODULE_PATH="${{ steps.resolve.outputs.module_path }}" | ||
| fi | ||
| mkdir -p dist | ||
| python scripts/publish-module.py "$MODULE_PATH" -o dist | ||
| - name: Upload module artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: module-package | ||
| path: | | ||
| dist/*.tar.gz | ||
| dist/*.sha256 | ||