Home

Awesome

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:

License

The project is licensed under MIT.