|
| 1 | +name: publish packages |
| 2 | +permissions: |
| 3 | + contents: read |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + paths: |
| 9 | + - "js/**" |
| 10 | + - "py/**" |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +jobs: |
| 14 | + detect-changes: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + js_changed: ${{ steps.filter.outputs.js }} |
| 18 | + py_changed: ${{ steps.filter.outputs.py }} |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + - uses: dorny/paths-filter@v3 |
| 22 | + id: filter |
| 23 | + with: |
| 24 | + filters: | |
| 25 | + js: |
| 26 | + - "js/**" |
| 27 | + py: |
| 28 | + - "py/**" |
| 29 | +
|
| 30 | + publish-js: |
| 31 | + needs: detect-changes |
| 32 | + runs-on: ubuntu-latest |
| 33 | + if: needs.detect-changes.outputs.js_changed == 'true' || github.event_name == 'workflow_dispatch' |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - uses: actions/setup-node@v4 |
| 38 | + with: |
| 39 | + node-version: "22" |
| 40 | + registry-url: "https://registry.npmjs.org" |
| 41 | + |
| 42 | + - name: get version |
| 43 | + id: version |
| 44 | + run: | |
| 45 | + cd js |
| 46 | + VERSION=$(node -p "require('./package.json').version") |
| 47 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 48 | + echo "Publishing secuprompt@$VERSION" |
| 49 | +
|
| 50 | + - name: install deps |
| 51 | + run: cd js && npm ci |
| 52 | + |
| 53 | + - name: build |
| 54 | + run: cd js && npm run build |
| 55 | + |
| 56 | + - name: publish |
| 57 | + run: cd js && npm publish --access public |
| 58 | + env: |
| 59 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 60 | + |
| 61 | + - name: notify |
| 62 | + run: | |
| 63 | + echo "✅ Published secuprompt@${{ steps.version.outputs.version }}" |
| 64 | +
|
| 65 | + publish-py: |
| 66 | + needs: detect-changes |
| 67 | + runs-on: ubuntu-latest |
| 68 | + if: needs.detect-changes.outputs.py_changed == 'true' || github.event_name == 'workflow_dispatch' |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v4 |
| 71 | + |
| 72 | + - uses: actions/setup-python@v5 |
| 73 | + with: |
| 74 | + python-version: "3.11" |
| 75 | + |
| 76 | + - name: get version |
| 77 | + id: version |
| 78 | + run: | |
| 79 | + VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])") |
| 80 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 81 | + echo "Publishing secuprompt@$VERSION" |
| 82 | +
|
| 83 | + - name: install build tools |
| 84 | + run: pip install build twine |
| 85 | + |
| 86 | + - name: build |
| 87 | + run: python -m build --outdir pydist |
| 88 | + |
| 89 | + - name: publish |
| 90 | + run: python -m twine upload pydist/* --skip-existing |
| 91 | + env: |
| 92 | + TWINE_USERNAME: __token__ |
| 93 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 94 | + |
| 95 | + - name: notify |
| 96 | + run: | |
| 97 | + echo "✅ Published secuprompt@${{ steps.version.outputs.version }}" |
0 commit comments