Skip to content
upload-cloud

GitHub Action

JSII Publish

v0.14.0 Latest version

JSII Publish

upload-cloud

JSII Publish

Builds and publishes JSII packages

Installation

Copy and paste the following snippet into your .yml file.

              

- name: JSII Publish

uses: udondan/jsii-publish@v0.14.0

Learn more about this action in udondan/jsii-publish

Choose a version

Dockerfile and GitHub action for publishing JSII packages

DEPRECATED: Please use publib

GitHub release (latest by date) Docker Cloud Build Status Docker Cloud Automated build Docker Pulls GitHub

Package building and publishing to npm, PyPI, NuGet and Maven (GitHub).

Examples

GitHub workflow

---
name: Publish packages

on:
  push:
    tags:
      - "v*"

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Get the version
        id: get_version
        run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}

      - name: Checkout code
        uses: actions/checkout@v1
        with:
          fetch-depth: 1

      - name: Publish packages
        uses: udondan/jsii-publish@v0.14.0
        with:
          VERSION: ${{ steps.get_version.outputs.VERSION }}
          BUILD_SOURCE: true
          BUILD_PACKAGES: true
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
          PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
          NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GITHUB_REPOSITORY: ${{ github.repository }}

In above example all actions are executed in the same step. You as well can split the actions into separate steps like so:

---
name: Publish packages

on:
  push:
    tags:
      - "v*"

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Get the version
        id: get_version
        run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}

      - name: Checkout code
        uses: actions/checkout@v1
        with:
          fetch-depth: 1

      - name: Build source
        uses: udondan/jsii-publish@v0.14.0
        with:
          VERSION: ${{ steps.get_version.outputs.VERSION }}
          BUILD_SOURCE: true

      - name: Build packages
        uses: udondan/jsii-publish@v0.14.0
        with:
          BUILD_PACKAGES: true

      - name: Publish to npm
        uses: udondan/jsii-publish@v0.14.0
        with:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

      - name: Publish to PyPI
        uses: udondan/jsii-publish@v0.14.0
        with:
          PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

      - name: Publish to NuGet
        uses: udondan/jsii-publish@v0.14.0
        with:
          NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}

      - name: Publish to Maven GitHub
        uses: udondan/jsii-publish@v0.14.0
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GITHUB_REPOSITORY: ${{ github.repository }}

Running the Docker image locally

docker run -it \
    --workdir /workdir \
    --volume $(pwd):/workdir \
    --env VERSION=0.3.0 \
    --env BUILD_SOURCE=true \
    --env BUILD_PACKAGES=true \
    --env NPM_TOKEN \
    --env PYPI_TOKEN \
    --env NUGET_TOKEN \
    --env GITHUB_TOKEN \
    --env GITHUB_REPOSITORY="${OWNER}/${REPOSITORY}" \
    udondan/jsii-publish:0.14.0

The package code can be mounted to any location in the container. Just make sure you set the workdir to the same value. In the example above I use /workdir.

Parameters passed per env:

  • VERSION: If set, the version in package.json will be updated with this value
  • BUILD_SOURCE: If true, the source will be compiled from TS to JS
  • BUILD_PACKAGES: If true, all configured JSII packages will be built
  • CLEANUP: If true, deletes the dist directory after publishing
  • NPM_TOKEN: Your publish token for npm. If passed, package will be published to npm
  • PYPI_TOKEN: Your publish token for PyPI. If passed, package will be published to PyPI
  • NUGET_TOKEN: Your publish token for NuGet. If passed, package will be published to NuGet
  • GITHUB_TOKEN: The token to interact with GitHub. If passed, the Maven package will be published to GitHub packages. If you run the GitHub action, the token will be automatically be generated byu GitHub and is available as ${{ GITHUB_TOKEN }}. If you run the Docker image yourself, you need to pass in a personal access token with read:packages and write:packages capabilities.
  • GITHUB_REPOSITORY: The url slug of your repository, which is ${OWNER}/${REPOSITORY}. In a github action you can just pass ${{ github.repository }}
  • DEBUG: If true, debug mode is enabled. Might leak secrets in output
  • NPM_OPTIONS: Command options to append to the npm publish command
  • PYPI_OPTIONS: Command options to append to the twine upload command
  • NUGET_OPTIONS: Command options to append to the dotnet nuget push command

License

The project is licensed under MIT.