Skip to content
This repository has been archived by the owner on Feb 19, 2023. It is now read-only.
/ jsii-publish Public archive

Dockerfile and Github action for publishing JSII packages

License

Notifications You must be signed in to change notification settings

udondan/jsii-publish

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

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/[email protected]
        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/[email protected]
        with:
          VERSION: ${{ steps.get_version.outputs.VERSION }}
          BUILD_SOURCE: true

      - name: Build packages
        uses: udondan/[email protected]
        with:
          BUILD_PACKAGES: true

      - name: Publish to npm
        uses: udondan/[email protected]
        with:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

      - name: Publish to PyPI
        uses: udondan/[email protected]
        with:
          PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

      - name: Publish to NuGet
        uses: udondan/[email protected]
        with:
          NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}

      - name: Publish to Maven GitHub
        uses: udondan/[email protected]
        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.