Skip to content

fix: Build frontend package before publishing to npm #25

fix: Build frontend package before publishing to npm

fix: Build frontend package before publishing to npm #25

Workflow file for this run

name: Semantic Release
on:
push:
branches: [main]
jobs:
run_backend_tests:
uses: ./.github/workflows/backend-ci.yml
release:
needs: run_backend_tests
runs-on: ubuntu-latest
if: github.ref_name == 'main'
concurrency:
group: ${{ github.workflow }}-release-${{ github.ref_name }}
cancel-in-progress: false
permissions:
contents: write
steps:
# Note: We checkout the repository at the branch that triggered the workflow.
# Python Semantic Release will automatically convert shallow clones to full clones
# if needed to ensure proper history evaluation. However, we forcefully reset the
# branch to the workflow sha because it is possible that the branch was updated
# while the workflow was running, which prevents accidentally releasing un-evaluated
# changes.
- name: Setup | Checkout Repository on Release Branch
uses: actions/checkout@v6
with:
ref: ${{ github.ref_name }}
- name: Setup | Force release branch to be at workflow sha
run: |
git reset --hard ${{ github.sha }}
- name: Action | Semantic Version Release
id: release
# Adjust tag with desired version if applicable.
uses: python-semantic-release/python-semantic-release@v10.5.3
with:
github_token: ${{ secrets.OPENEDX_SEMANTIC_RELEASE_GITHUB_TOKEN }}
git_committer_name: "github-actions"
git_committer_email: "actions@users.noreply.github.com"
changelog: "false"
directory: './backend'
- name: Publish | Upload to GitHub Release Assets
uses: python-semantic-release/publish-action@v10.5.3
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.OPENEDX_SEMANTIC_RELEASE_GITHUB_TOKEN }}
tag: ${{ steps.release.outputs.tag }}
directory: './backend'
- name: Upload | Distribution Artifacts
uses: actions/upload-artifact@v4
if: steps.release.outputs.released == 'true'
with:
name: distribution-artifacts
path: backend/dist
if-no-files-found: error
outputs:
released: ${{ steps.release.outputs.released || 'false' }}
version: ${{ steps.release.outputs.version }}
publish_to_pypi:
# 1. Separate out the publish step from the github release step to run each step at
# the least amount of token privilege
# 2. Also, publishing can fail, and its better to have a separate job if you need to retry
# and it won't require reversing the release.
runs-on: ubuntu-latest
needs: release
if: github.ref_name == 'main' && needs.release.outputs.released == 'true'
permissions:
contents: read
id-token: write
steps:
- name: Setup | Download Build Artifacts
uses: actions/download-artifact@v4
id: artifact-download
with:
name: distribution-artifacts
path: backend/dist
- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: backend/dist
user: __token__
password: ${{ secrets.PYPI_UPLOAD_TOKEN }}
publish_to_npm:
runs-on: ubuntu-latest
needs: release
if: github.ref_name == 'main' && needs.release.outputs.released == 'true'
permissions:
contents: read
id-token: write
steps:
- name: Setup | Checkout Repository on Release Ref
uses: actions/checkout@v6
with:
ref: ${{ github.sha }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: './frontend/.nvmrc'
- name: Update the package version and publish
run: |
npm install --include=dev
npm version ${{ needs.release.outputs.version }}
npm run build
npm publish
working-directory: './frontend'