Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add assertPrerelease option to stop releases outside of release.yml #30

Merged
merged 8 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ inputs:
python-version:
description: The version of Python being used in the provider
required: true
assertPrerelease:
description: |
Assert that `version` argument describes a pre-release.

`assertPrerelease` should be set wherever you *do not* want to publish releases
from, like CI.
sdk:
description: |
The name of the language SDK being published.
Expand Down Expand Up @@ -53,6 +59,14 @@ runs:
- name: Verify input
run: echo 'Publishing SDK:' && echo ${{ inputs.sdk }}
shell: bash
- name: Assert pre-release
if: ${{ inputs.assertPrerelease == 'true' }}
run: |
if [[ "${{ inputs.version }}" =~ "^v[0-9]+\.[0-9]+\.[0-9]+$" ]] then
echo "It looks like you have attempted to publish a non-alpha release by accident."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love there to be a link to this tool's README but am honestly not sure how to do it succinctly.

exit 1;
fi
shell: bash
- name: Checkout Repo
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -88,22 +102,24 @@ runs:
- name: Nodejs - Publish to NPM
uses: ./.pulumi-package-publish/lang/nodejs
if: (contains(inputs.sdk, 'nodejs') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!nodejs')
env:
NODE_VERSTION: ${{ inputs.node-version }}
with:
version: ${{ inputs.version }}
node-version: ${{ inputs.node-version }}
- name: .NET - Publish to Nuget
if: (contains(inputs.sdk, 'dotnet') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!dotnet')
uses: ./.pulumi-package-publish/lang/dotnet
env:
DOTNET_VERSTION: ${{ inputs.dotnet-version }}
with:
version: ${{ inputs.version }}
dotnet-version: ${{ inputs.dotnet-version }}
- name: Python - Publish to PyPi
if: (contains(inputs.sdk, 'python') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!python')
uses: ./.pulumi-package-publish/lang/python
env:
PYTHON_VERSION: ${{ inputs.python-version }}
with:
version: ${{ inputs.version }}
python-version: ${{ inputs.python-version }}
- name: Java - Publish to Maven
if: (contains(inputs.sdk, 'java') || (contains(inputs.sdk, 'all') && !contains(inputs.sdk, '!all'))) && !contains(inputs.sdk, '!java')
uses: ./.pulumi-package-publish/lang/java
env:
PROVIDER_VERSION: ${{ inputs.version }}
JAVA_VERSION: ${{ inputs.java-version }}

with:
version: ${{ inputs.version }}
java-version: ${{ inputs.java-version }}
16 changes: 14 additions & 2 deletions lang/dotnet/action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
name: 'Publish to Nuget'
description: 'A subcomponent of pulumi-package-publish'
description: |
A subcomponent of pulumi-package-publish

inputs:
version:
description: >-
The version of the provider being published.

TODO: Validate that the SDK we are publishing matches this input.
required: true
dotnet-version:
description: The version of Dotnet being used in the provider
required: true

runs:
using: "composite"
steps:
- name: Setup DotNet
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
dotnet-version: ${{ inputs.dotnet-version }}
- name: Download dotnet SDK
uses: actions/download-artifact@v4
with:
Expand Down
13 changes: 11 additions & 2 deletions lang/java/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
name: 'Publish to Maven'
description: 'A subcomponent of pulumi-package-publish'
description: |
A subcomponent of pulumi-package-publish

inputs:
version:
description: The version of the provider being published.
required: true
java-version:
description: The version of Java being used in the provider
required: true

runs:
using: "composite"
Expand All @@ -9,7 +18,7 @@ runs:
with:
cache: gradle
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
java-version: ${{ inputs.java-version }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
Expand Down
25 changes: 23 additions & 2 deletions lang/nodejs/action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
name: 'Publish to NPM'
description: 'A subcomponent of pulumi-package-publish'
description: |
A subcomponent of pulumi-package-publish

inputs:
version:
description: The version of the provider being published.
required: true
node-version:
description: The version of Node being used in the provider
required: true

runs:
using: "composite"
steps:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ inputs.node-version }}
registry-url: https://registry.npmjs.org
- name: Download nodejs SDK
uses: actions/download-artifact@v4
Expand All @@ -18,6 +27,18 @@ runs:
run: tar -zxf ${{ github.workspace }}/sdk/nodejs.tar.gz -C
${{ github.workspace }}/sdk/nodejs
shell: bash
- name: Validate Package Version
shell: bash
# Ensure that we are publishing only the version that we expect (and that is set in
# inputs.version). Otherwise we could publish a version that doesn't match what we
# are trying to publish.
run: >-
ACTUAL="v$(cat ${{ github.workspace }}/sdk/nodejs/bin/package.json | jq .version --raw-output)" &&
JS="$(pulumictl convert-version --version "${{ inputs.version }}" --language javascript)" &&
if [[ "$ACTUAL" != "$JS" ]]; then
echo "Found version $ACTUAL does not match expected version $JS";
exit 1;
fi
- name: Run npm whoami
run: npm whoami
shell: bash
Expand Down
16 changes: 14 additions & 2 deletions lang/python/action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
name: 'Publish to PyPi'
description: 'A subcomponent of pulumi-package-publish'
description: |
A subcomponent of pulumi-package-publish

inputs:
version:
description: >-
The version of the provider being published.

TODO: Validate that the SDK we are publishing matches this input.
required: true
python-version:
description: The version of Python being used in the provider
required: true

runs:
using: "composite"
steps:
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
python-version: ${{ inputs.python-version }}
- name: Download python SDK
uses: actions/download-artifact@v4
with:
Expand Down