Merge pull request #1 from RitikShah/patch-1 #24
This file contains 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: Build and publish packages | |
on: | |
push: | |
branches: "*" | |
tags: "v*" | |
workflow_dispatch: | |
inputs: | |
release: | |
type: boolean | |
env: | |
PYTHON_VERSION: '3.11' | |
NODE_VERSION: '18.x' | |
jobs: | |
build-js: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install deps | |
run: npm ci | |
- name: Compile TypeScript | |
run: tsc --build | |
- name: Create tarball | |
id: pack | |
run: echo "tarball=$(npm pack)" >> "$GITHUB_OUTPUT" | |
- name: Upload package artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-js | |
path: ${{ steps.pack.outputs.tarball }} | |
build-py: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install . hatch | |
- name: Build package | |
run: hatch build | |
- name: Upload package artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-py | |
path: dist/py | |
publish-npm: | |
runs-on: ubuntu-latest | |
needs: [build-js, build-py] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') || github.event_name == 'workflow_dispatch' && inputs.release | |
outputs: | |
release: true | |
environment: | |
name: npm | |
url: https://www.npmjs.com/package/@leftsquarebracket/minecraft-render | |
permissions: | |
id-token: write | |
steps: | |
- name: Download package artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: build-js | |
path: dist | |
- name: Rename tarball | |
run: mv dist/*.tgz package.tgz | |
- name: Publish package | |
uses: JS-DevTools/npm-publish@v3 | |
with: | |
package: package.tgz | |
token: ${{ secrets.NPM_TOKEN }} | |
provenance: true | |
access: public | |
publish-pypi: | |
runs-on: ubuntu-latest | |
needs: [publish-npm] | |
if: needs.publish-npm.outputs.release | |
environment: | |
name: pypi | |
url: https://pypi.org/p/minecraft-render | |
permissions: | |
id-token: write | |
steps: | |
- name: Download package artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: build-py | |
path: dist | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@release/v1 |