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

Commit

Permalink
#8: adds functionality to pass in custom options for "npm publish", "…
Browse files Browse the repository at this point in the history
…twine upload" and "dotnet nuget push" (#9)
  • Loading branch information
udondan authored Jul 14, 2020
1 parent d697691 commit e4630a5
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 13 deletions.
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
fetch-depth: 1

- name: Publish packages
uses: udondan/jsii-publish@v0.8.3
uses: udondan/jsii-publish@v0.10.0
with:
VERSION: ${{ steps.get_version.outputs.VERSION }}
BUILD_SOURCE: true
Expand Down Expand Up @@ -74,33 +74,33 @@ jobs:
fetch-depth: 1

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

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

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

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

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

- name: Publish to Maven GitHub
uses: udondan/jsii-publish@v0.8.3
uses: udondan/jsii-publish@v0.10.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
Expand All @@ -120,7 +120,7 @@ docker run -it \
--env NUGET_TOKEN \
--env GITHUB_TOKEN \
--env GITHUB_REPOSITORY="${OWNER}/${REPOSITORY}" \
udondan/jsii-publish:0.8.3
udondan/jsii-publish:0.10.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`.
Expand All @@ -135,8 +135,11 @@ Parameters passed per env:
- **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](https://github.com/settings/tokens) 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**.
- **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

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.0
0.10.0
13 changes: 11 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ branding:
color: orange
runs:
using: docker
image: docker://udondan/jsii-publish:0.9.0
image: docker://udondan/jsii-publish:0.10.0
inputs:
BUILD_SOURCE:
description: Indicates if the source should be build (tsc)
Expand All @@ -31,8 +31,17 @@ inputs:
description: Your publish token for GitHub. If passed, Maven package will be published to Github
required: false
GITHUB_REPOSITORY:
description: GitHub repository path. OWNER/REPO, e.g. "udondan/jsii-publish". You can just pass in "{{ github.repository }}"
description: GitHub repository path. OWNER/REPO, e.g. `udondan/jsii-publish`. You can just pass in `{{ github.repository }}`
required: false
DEBUG:
description: Enables debug mode
default: false
NPM_OPTIONS:
description: Command options to append to the `npm publish` command
required: false
PYPI_OPTIONS:
description: Command options to append to the `twine upload` command
required: false
NUGET_OPTIONS:
description: Command options to append to the `dotnet nuget push` command
required: false
3 changes: 3 additions & 0 deletions scripts/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ var PYPI_TOKEN
var NUGET_TOKEN
var GITHUB_TOKEN
var GITHUB_REPOSITORY
var NPM_OPTIONS
var PYPI_OPTIONS
var NUGET_OPTIONS

if [[ "${DEBUG}" = true ]]; then
set -x
Expand Down
5 changes: 5 additions & 0 deletions scripts/publish/npm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ publish_to_npm() {
if [[ "${DEBUG}" = true ]]; then
cmd+=(--verbose)
fi

if [ -n "${NPM_OPTIONS}" ]; then
cmd+=("${NPM_OPTIONS}")
fi

cmd+=("$1")

eval "${cmd[@]}"
Expand Down
5 changes: 5 additions & 0 deletions scripts/publish/nuget
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ publish_to_nuget() {
if [[ "${DEBUG}" = true ]]; then
cmd+=(--verbosity Debug)
fi

if [ -n "${NUGET_OPTIONS}" ]; then
cmd+=("${NUGET_OPTIONS}")
fi

cmd+=(push "$1" -k "${NUGET_TOKEN}" -s https://api.nuget.org/v3/index.json --skip-duplicate)

eval "${cmd[@]}"
Expand Down
5 changes: 5 additions & 0 deletions scripts/publish/pypi
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ EOF
if [[ "${DEBUG}" = true ]]; then
cmd+=(--verbose)
fi

if [ -n "${PYPI_OPTIONS}" ]; then
cmd+=("${PYPI_OPTIONS}")
fi

cmd+=("$1/*")

eval "${cmd[@]}"
Expand Down

0 comments on commit e4630a5

Please sign in to comment.