Skip to content

Commit

Permalink
Publish dev versions of the python and node SDKs (#15299)
Browse files Browse the repository at this point in the history
Publish dev versions of the python and node SDKs, so we can consume them
pre-release and make our releases more stable.

Also clean up the publish_npm.sh script a little bit, removing now
unused cruft.
  • Loading branch information
tgummerer committed Feb 15, 2024
1 parent 11eff25 commit cf9562c
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 13 deletions.
121 changes: 119 additions & 2 deletions .github/workflows/ci-dev-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ jobs:
- name: strip prefix
id: strip-prefix
run: |
version="${{ steps.ghd.outputs.describe }}"
version="${version#v}"
short_sha="${{ steps.ghd.outputs.short-sha }}"
version="${{ inputs.version }}"
version="${version#v}-alpha.${short_sha}"
echo dev-version="$version" >>"${GITHUB_OUTPUT}"
outputs:
dev-version: ${{ steps.strip-prefix.outputs.dev-version }}
Expand Down Expand Up @@ -87,6 +88,16 @@ jobs:
enable-coverage: false
secrets: inherit

build-sdks:
name: Build SDKs
needs: [matrix, gather-info]
uses: ./.github/workflows/ci-build-sdks.yml
with:
ref: ${{ inputs.ref }}
version: ${{ needs.gather-info.outputs.dev-version }}
version-set: ${{ needs.matrix.outputs.version-set }}
secrets: inherit

sign:
name: sign
needs: [build-release]
Expand All @@ -95,6 +106,112 @@ jobs:
ref: ${{ inputs.ref }}
version: ${{ inputs.version }}

# Check if we need to create a new SDK dev release
sdk-check-release:
name: sdk-check-release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check for changes
id: check-changes
run: |
if git diff --exit-code master...HEAD sdk/nodejs; then
echo "nodejs-release=true" >>"${GITHUB_OUTPUT}"
else
echo "nodejs-release=false" >>"${GITHUB_OUTPUT}"
fi
if git diff --exit-code master...HEAD sdk/python; then
echo "python-release=true" >>"${GITHUB_OUTPUT}"
else
echo "python-release=false" >>"${GITHUB_OUTPUT}"
fi
outputs:
nodejs-release: ${{ steps.check-changes.outputs.nodejs-release }}
python-release: ${{ steps.check-changes.outputs.python-release }}

nodejs-dev-sdk-release:
needs: [gather-info, build-sdks, sdk-check-release, matrix]
runs-on: ubuntu-latest
# if: ${{ needs.sdk-check-release.outputs.nodejs-release }} #TODO: enable this after testing
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Make artifacts directory
run: |
mkdir -p artifacts.tmp
- name: Download artifacts from previous step
uses: actions/download-artifact@v2
with:
path: artifacts.tmp
- name: Move artifacts to the right place
run: |
mkdir -p artifacts
(
cd artifacts.tmp/artifacts-nodejs-sdk
version="${{ inputs.version }}"
for file in *"${version}"-alpha*.tgz ; do
mv -vT "$file" "../../artifacts/sdk-nodejs-${file}"
done
)
- name: Set up Node ${{ fromJson(needs.matrix.outputs.version-set).nodejs }}
uses: actions/setup-node@v3
with:
node-version: ${{ fromJson(needs.matrix.outputs.version-set).nodejs }}
registry-url: https://registry.npmjs.org
always-auth: true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish nodejs release
run: |
find artifacts
make -C sdk/nodejs publish
env:
PULUMI_VERSION: ${{ needs.gather-info.outputs.dev-version }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_REF: ${{ inputs.ref }}


python-dev-sdk-release:
needs: [gather-info, build-sdks, sdk-check-release]
runs-on: ubuntu-latest
# if: ${{ needs.sdk-check-release.outputs.python-release }} # TODO: enable this after testing
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Make artifacts directory
run: |
mkdir -p artifacts.tmp
- name: Download artifacts from previous step
uses: actions/download-artifact@v2
with:
path: artifacts.tmp
- name: Move artifacts to the right place
run: |
mkdir -p artifacts
version="${{ inputs.version }}"
mkdir -p artifacts
(
cd artifacts.tmp/artifacts-python-sdk
for file in *"${version}a"*.whl ; do
mv -vT "$file" "../../artifacts/sdk-python-${file}"
done
)
- name: Install Python deps
run: |
python -m pip install --upgrade pip requests wheel urllib3 chardet twine
- name: Publish python release
run: |
find artifacts
make -C sdk/python publish
env:
PYPI_USERNAME: __token__
PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}

s3-blobs:
name: s3 blobs
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- type: feat
scope: sdk/nodejs,python
description: Publish dev versions of the nodejs and python SDKs
12 changes: 2 additions & 10 deletions scripts/publish_npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,14 @@ PKG_NAME=$(jq -r .name < "${ROOT}/sdk/nodejs/package.json")
# shellcheck disable=SC2154 # assigned by release.yml
PKG_VERSION="${PULUMI_VERSION}"

# If the package doesn't have an alpha tag, use the tag of latest instead of
# If the package isn't a dev version (includes the git describe output in its
# version string), use the tag of latest instead of
# dev. NPM uses this tag as the default version to add, so we want it to mean
# the newest released version.
if [[ "${PKG_VERSION}" != *-alpha* ]]; then
NPM_TAG="latest"
fi

# we need to set explicit beta and rc tags to ensure that we don't mutate to use the latest tag
if [[ "${PKG_VERSION}" == *-beta* ]]; then
NPM_TAG="beta"
fi

if [[ "${PKG_VERSION}" == *-rc* ]]; then
NPM_TAG="rc"
fi

# Now, perform the publish. The logic here is a little goofy because npm provides
# no way to say "if the package already exists, don't fail" but we want these
# semantics (so, for example, we can restart builds which may have failed after
Expand Down
2 changes: 1 addition & 1 deletion scripts/pulumi-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fi

case "${LANGUAGE}" in
python)
echo -n "${VERSION}" | sed 's/-alpha./a/; s/-beta./b/; s/-rc./rc/; s/-dev./dev/'
echo -n "${VERSION}" | sed "s/-alpha.*/a$(date +%s)/"
;;
*)
echo -n "${VERSION}"
Expand Down

0 comments on commit cf9562c

Please sign in to comment.