diff --git a/.github/workflows/packaging.yml b/.github/workflows/packaging.yml index 345f61977..7d773ca8d 100644 --- a/.github/workflows/packaging.yml +++ b/.github/workflows/packaging.yml @@ -23,8 +23,8 @@ on: env: - PYTHON_VERSION: "3.9" - NODE_VERSION: "14.x" + PYTHON_VERSION: "3.10" + NODE_VERSION: "16.x" jobs: @@ -130,7 +130,7 @@ jobs: with: fetch-depth: 0 - - name: Get TRAC d.a.p. version + - name: Get TRAC version id: tracdap-version run: | tracdap_version=`dev/version.sh` @@ -161,3 +161,84 @@ jobs: asset_path: tracdap-dist-packages-${{ steps.tracdap-version.outputs.tracdap_version }}.tgz asset_name: tracdap-dist-packages-${{ steps.tracdap-version.outputs.tracdap_version }}.tgz asset_content_type: application/gzip + + publish_to_pypi: + + if: ${{ github.event_name == 'release' && github.event.action == 'published' }} + + runs-on: ubuntu-latest + + needs: + - python_runtime_package + + steps: + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install Twine + run: | + python -m pip install --upgrade pip + pip install twine + + - name: Fetch Python runtime package + uses: actions/download-artifact@v2 + with: + name: python_runtime_package + path: tracdap_dist/ + + - name: Publish to PyPI + env: + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + run: | + ls tracdap_dist/* + twine upload --username __token__ tracdap_dist/* + + publish_to_npm: + + if: ${{ github.event_name == 'release' && github.event.action == 'published' }} + + runs-on: ubuntu-latest + + needs: + - web_api_package + + steps: + + # fetch-depth = 0 is needed to get tags for version info + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Get TRAC version + id: tracdap-version + run: | + tracdap_version=`dev/version.sh` + echo "tracdap_version = ${tracdap_version}" + echo "::set-output name=tracdap_version::${tracdap_version}" + + tracdap_tag=`dev/version_tag.sh ${tracdap_version}` + echo "tracdap_tag = ${tracdap_tag}" + echo "::set-output name=tracdap_tag::${tracdap_tag}" + + - name: Fetch web API package + uses: actions/download-artifact@v2 + with: + name: web_api_package + path: tracdap_dist/ + + # NPM publish wants a folder in NPM layout + # So, extract the tarball and publish using the NPM package files + # Also, add an entry in .npmrc to tell NPM to use an auth token from the environment + - name: Publish to NPM + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_TAG: ${{ steps.tracdap-version.outputs.tracdap_tag }} + run: | + tar -xzvf tracdap_dist/* + cd package + echo //registry.npmjs.org/:_authToken=\$\{NPM_TOKEN\} >> .npmrc + npm publish --access public --tag ${NPM_TAG} diff --git a/dev/version_tag.sh b/dev/version_tag.sh new file mode 100755 index 000000000..43a60c540 --- /dev/null +++ b/dev/version_tag.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env sh + +# Copyright 2022 Accenture Global Solutions Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For NPM Publish, we need to specify a release tag +# This ia a quick way to generate the tag based on the full version string +# The version number should be as output from version.sh + +VERSION=$1 + +if echo $VERSION | grep -qv "^[0-9]\+\.[0-9]\+\.[0-9]\+"; then + echo "invalid" + exit -1 +elif echo $VERSION | grep -q "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; then + echo "latest" +elif echo $VERSION | grep -q "dev"; then + echo "dev" +elif echo $VERSION | grep -q "alpha"; then + echo "alpha" +elif echo $VERSION | grep -q "beta"; then + echo "beta" +elif echo $VERSION | grep -q "rc"; then + echo "rc" +else + echo "invalid" + exit -1 +fi