From 2d66dc90db63e592b856d136f05c0520e09d6d45 Mon Sep 17 00:00:00 2001 From: Alex Hadley Date: Thu, 29 Aug 2024 13:52:55 -0400 Subject: [PATCH] Add publish to PyPI workflow --- .github/workflows/github-pages.yml | 87 ------------------------------ .github/workflows/publish.yml | 50 +++++++++++++++++ 2 files changed, 50 insertions(+), 87 deletions(-) delete mode 100644 .github/workflows/github-pages.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml deleted file mode 100644 index 1fb8dae..0000000 --- a/.github/workflows/github-pages.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: Deploy to GitHub Pages - -on: workflow_dispatch - -env: - HATCH_VERSION: "1.12.0" - PACKAGE_VERSION: "0.1.1" - PACKAGE_NAME: "jupyterlab-open-warning" - PYTHON_PACKAGE_NAME: "jupyterlab_open_warning" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Hatch - run: pipx install hatch==${{ env.HATCH_VERSION }} - - - name: Set up Node - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - - - name: Yarn cache - uses: actions/cache@v4 - with: - path: .yarn/cache - key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }} - restore-keys: | - yarn-${{ runner.os }}- - - - name: Build package - run: hatch build - - - name: Fix file permissions - run: chmod +r dist/* - - - name: Create _site/releases/index.html - run: | - mkdir _site - mkdir _site/releases - echo ' - - - ${{ env.PACKAGE_NAME }} - - ' > _site/releases/index.html - - - name: Create _site/releases//index.html - run: | - mkdir _site/releases/${{ env.PACKAGE_NAME }} - echo ' - - - - ${{ env.PYTHON_PACKAGE_NAME }}-${{ env.PACKAGE_VERSION }}-py3-none-any.whl - - - ${{ env.PYTHON_PACKAGE_NAME }}-${{ env.PACKAGE_VERSION }}.tar.gz - - - ' > _site/releases/${{ env.PACKAGE_NAME }}/index.html - - - name: Create _site/latest.tar.gz - run: cp dist/*.tar.gz _site/latest.tar.gz - - - name: Move package files into _site/releases/ - run: mv dist/* _site/releases/${{ env.PACKAGE_NAME }} - - - name: Upload site artifact - uses: actions/upload-pages-artifact@v3 - - deploy: - needs: build - permissions: - pages: write - id-token: write - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..388ddd8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,50 @@ +name: Publish + +on: + release: + types: [published] + +env: + HATCH_VERSION: "1.12.0" + PACKAGE_NAME: "jupyterlab-open-warning" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Hatch + run: pipx install hatch==${{ env.HATCH_VERSION }} + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + + - name: Build package + run: hatch build + + - name: Upload package artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }}-release + path: dist + + publish: + needs: build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/${{ env.PACKAGE_NAME }} + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + name: ${{ env.PACKAGE_NAME }}-release + path: dist + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1