Skip to content

Commit

Permalink
Add include/exclude logic to sdk:
Browse files Browse the repository at this point in the history
  • Loading branch information
iwahbe committed Dec 27, 2023
1 parent 39e3d5b commit c1e5b3c
Showing 1 changed file with 47 additions and 21 deletions.
68 changes: 47 additions & 21 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,36 @@ name: 'Pulumi Package publisher'
description: 'A GitHub Action that publishes provider SDKs'
inputs:
sdk:
description: The name of the language SDK being published
description: |
The name of the language SDK being published.
To enable a single language, specify that language:
sdk: nodejs
To enable multiple languages, specify them:
sdk: nodejs,python
To enable all languages (the default), specify 'all':
sdk: all
To disable only a single language (but enable all others), use:
sdk: all,!nodejs
required: false
default: 'all'

# The if: statement for the above is:
#
# if: (contains(inputs.sdk, '${LANGUAGE}') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!${LANGUAGE}')
#
# If can be read as:
#
# If (${LANGUAGE} or all (but not !all)) and not !${LANGUAGE}

runs:
using: "composite"
steps:
Expand All @@ -30,77 +56,77 @@ runs:
- name: Install Pulumi CLI
uses: pulumi/action-install-pulumi-cli@v2
- name: Setup Node
if: inputs.sdk == 'nodejs' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'nodejs') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!nodejs')
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODEVERSION }}
registry-url: https://registry.npmjs.org
- name: Download nodejs SDK
if: inputs.sdk == 'nodejs' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'nodejs') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!nodejs')
uses: actions/download-artifact@v2
with:
name: nodejs-sdk.tar.gz
path: ${{ github.workspace }}/sdk/
- name: Uncompress nodejs SDK
if: inputs.sdk == 'nodejs' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'nodejs') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!nodejs')
run: tar -zxf ${{ github.workspace }}/sdk/nodejs.tar.gz -C
${{ github.workspace }}/sdk/nodejs
shell: bash
- name: Run npm whoami
if: inputs.sdk == 'nodejs' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'nodejs') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!nodejs')
run: npm whoami
shell: bash
env:
NODE_AUTH_TOKEN: ${{ env.NODE_AUTH_TOKEN }}
- name: Publish Node
if: inputs.sdk == 'nodejs' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'nodejs') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!nodejs')
run: pulumi package publish-sdk nodejs --path ${{ github.workspace }}/sdk/nodejs/bin
shell: bash
env:
NODE_AUTH_TOKEN: ${{ env.NODE_AUTH_TOKEN }}
- name: Setup DotNet
if: inputs.sdk == 'dotnet' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'dotnet') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!dotnet')
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNETVERSION }}
- name: Download dotnet SDK
if: inputs.sdk == 'dotnet' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'dotnet') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!dotnet')
uses: actions/download-artifact@v2
with:
name: dotnet-sdk.tar.gz
path: ${{ github.workspace }}/sdk/
- name: Uncompress dotnet SDK
if: inputs.sdk == 'dotnet' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'dotnet') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!dotnet')
run: tar -zxf ${{ github.workspace }}/sdk/dotnet.tar.gz -C
${{ github.workspace }}/sdk/dotnet
shell: bash
- name: Publish dotnet SDK
if: inputs.sdk == 'dotnet' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'dotnet') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!dotnet')
run: find "${{ github.workspace }}/sdk/dotnet/bin/Debug/" -name 'Pulumi.*.nupkg'
-exec dotnet nuget push -k "${NUGET_PUBLISH_KEY}" -s https://api.nuget.org/v3/index.json {} \;
shell: bash
- name: Setup Python
if: inputs.sdk == 'python' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'python') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!python')
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHONVERSION }}
- name: Download python SDK
if: inputs.sdk == 'python' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'python') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!python')
uses: actions/download-artifact@v2
with:
name: python-sdk.tar.gz
path: ${{ github.workspace }}/sdk/
- name: Uncompress python SDK
if: inputs.sdk == 'python' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'python') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!python')
run: tar -zxf ${{ github.workspace }}/sdk/python.tar.gz -C
${{ github.workspace }}/sdk/python
shell: bash
- name: Install Twine
if: inputs.sdk == 'python' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'python') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!python')
run: python -m pip install pip twine
shell: bash
- name: Publish Python SDK
if: inputs.sdk == 'python' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'python') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!python')
run: if [ -n "${PYPI_USERNAME}" ] ;
then PYPI_PUBLISH_USERNAME=${PYPI_USERNAME};
else PYPI_PUBLISH_USERNAME="pulumi";
Expand All @@ -113,35 +139,35 @@ runs:
--verbose
shell: bash
- name: Setup Java
if: inputs.sdk == 'java' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'java') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!java')
uses: actions/setup-java@v3
with:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVAVERSION }}
- name: Setup Gradle
if: inputs.sdk == 'java' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'java') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!java')
uses: gradle/gradle-build-action@v2
with:
gradle-version: "7.6"
- name: Download java SDK
if: inputs.sdk == 'java' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'java') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!java')
uses: actions/download-artifact@v2
with:
name: java-sdk.tar.gz
path: ${{ github.workspace}}/sdk/
- name: Uncompress java SDK
if: inputs.sdk == 'java' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'java') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!java')
run: tar -zxf ${{github.workspace}}/sdk/java.tar.gz -C
${{github.workspace}}/sdk/java
shell: bash
- name: Set PACKAGE_VERSION to Env
if: inputs.sdk == 'java' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'java') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!java')
run: echo "PACKAGE_VERSION=$(pulumictl get version --language generic)" >>
$GITHUB_ENV
shell: bash
- name: Publish Java SDK
if: inputs.sdk == 'java' || inputs.sdk == 'all'
if: (contains(inputs.sdk, 'java') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!java')
continue-on-error: true
uses: gradle/gradle-build-action@9b814496b50909128c6a52622b416c5ffa04db49
with:
Expand Down

0 comments on commit c1e5b3c

Please sign in to comment.