Skip to content

Release package

Release package #50

Workflow file for this run

name: Release package
on:
workflow_dispatch:
inputs:
release-level:
description: "Release level"
required: true
type: choice
default: prerelease
options:
- prerelease
- patch
- minor
- major
release-kind:
description: "Release kind"
required: false
type: choice
default: alpha
options:
- alpha
- beta
- rc
- stable
host:
description: "Which host package to release"
required: true
type: choice
options:
- js
- python
- all
jobs:
core:
name: Core
runs-on: ubuntu-latest
steps:
# checkout
- uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
# setup
- uses: actions/setup-node@v3
with:
registry-url: https://registry.npmjs.org/
node-version: "18"
cache: yarn
cache-dependency-path: integration/yarn.lock
- name: Cache cargo registry and build directory
uses: actions/cache@v3
with:
path: |
~/.cargo/git
~/.cargo/registry/cache
~/.cargo/registry/index
core/target
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-release
restore-keys: |
cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
cargo-${{ runner.os }}-
- name: Cache WASI SDK
uses: actions/cache@v3
with:
path: core/wasi-sdk-*
key: wasisdk-${{ runner.os }}-${{ runner.arch }}
- name: Install wasm-opt
run: |
sudo apt-get update
sudo apt-get install binaryen
- name: Install rust target
run: rustup target add wasm32-wasi
# build and store
- name: Run make to build core
env:
CARGO_INCREMENTAL: "0" # disable incremental to reduce load on the cache
run: make build_core CORE_PROFILE=release OS=${{ runner.os }}
- name: Upload artifact core-async.wasm
uses: actions/upload-artifact@v3
with:
name: core-async-wasm
path: core/dist/core-async.wasm
- name: Upload artifact core.wasm
uses: actions/upload-artifact@v3
with:
name: core-wasm
path: core/dist/core.wasm
# TODO: Changelog update create tag and GitHub release
host-javascript-prepare:
name: Prepare JavaScript Host
needs: [core, host-python-prepare]
# when host-python is skipped this job should still run if inputs allow
# so we need to include a status check, then manually ensure core build didn't fail
# (see https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions)
if: ${{ !cancelled() && needs.core.result == 'success' && (inputs.host == 'js' || inputs.host == 'all') }}
runs-on: ubuntu-latest
outputs:
RELEASE_VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }}
RELEASE_LEVEL: ${{ steps.release-level.outputs.RELEASE_LEVEL }}
RELEASE_TAG: ${{ steps.release-level.outputs.RELEASE_TAG }}
RELEASE_PREID: ${{ steps.release-level.outputs.RELEASE_PREID }}
steps:
# Setup
- uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- name: Git configuration
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions release workflow"
- uses: actions/setup-node@v3
with:
registry-url: https://registry.npmjs.org/
node-version: "18"
cache: yarn
cache-dependency-path: host/javascript/yarn.lock
# Release version
- name: Resolve release level
id: release-level
run: scripts/release-level.sh ${{ inputs.release-level }} ${{ inputs.release-kind }} >>$GITHUB_OUTPUT
- name: Resolve release version
id: release-version
run: scripts/release-version.sh ./host/javascript/VERSION ${{ steps.release-level.outputs.RELEASE_LEVEL }} ${{ steps.release-level.outputs.RELEASE_PREID }} >>$GITHUB_OUTPUT
# Update version
- name: Update version in package.json
working-directory: host/python
run: yarn version --no-git-tag-version --new-version ${{ steps.release-version.outputs.RELEASE_VERSION }}
# Build
- uses: actions/download-artifact@v3
with:
name: core-async-wasm
path: host/javascript/assets
- name: Copy LICENSE
run: cp LICENSE host/javascript/LICENSE
- name: Build host/javascript
working-directory: host/javascript
run: |
yarn install --frozen-lockfile
yarn build
# Changelog
- name: Update changelog
uses: superfaceai/release-changelog-action@v1
if: ${{ steps.release-level.outputs.RELEASE_TAG == 'latest' }}
with:
path-to-changelog: host/javascript/CHANGELOG.md
version: ${{ steps.release-version.outputs.RELEASE_VERSION }}
operation: release
# Commit release changes
- name: Git configuration
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions release workflow"
- name: Commit package.json, VERSION, CHANGELOG.md and create git tag
working-directory: host/javascript
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add package.json VERSION CHANGELOG.md
git commit -m "chore: release host/javascript ${{ steps.release-version.outputs.RELEASE_VERSION }}"
git tag "js-v${{ steps.release-version.outputs.RELEASE_VERSION }}"
git push origin
git push origin --tags
# Create GitHub Release
- name: Version for Changelog entry
id: get-changelog-version
env:
RELEASE_TAG: ${{ steps.release-level.outputs.RELEASE_TAG }}
VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }}
run: |
if [ "$RELEASE_TAG" = "latest" ]; then
echo VERSION="$VERSION"
else
echo VERSION="" # refers to unreleased section
fi
- name: Get release version changelog
id: get-changelog
uses: superfaceai/release-changelog-action@v1
with:
path-to-changelog: host/javascript/CHANGELOG.md
version: ${{ steps.get-changelog-version.outputs.VERSION }}
operation: read
- name: Update GitHub release documentation
uses: softprops/action-gh-release@v1
with:
tag_name: "js-v${{ steps.release-version.outputs.RELEASE_VERSION }}"
body: ${{ steps.get-changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
host-javascript-publish:
name: Publish JavaScript Host
needs: [core, host-javascript-prepare]
if: ${{ !cancelled() && needs.host-javascript-prepare.result == 'success' }}
runs-on: ubuntu-latest
steps:
# Setup
- uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- uses: actions/setup-node@v3
with:
registry-url: https://registry.npmjs.org/
node-version: "18"
cache: yarn
cache-dependency-path: host/javascript/yarn.lock
# Build
- uses: actions/download-artifact@v3
with:
name: core-async-wasm
path: host/javascript/assets
- name: Copy LICENSE
run: cp LICENSE host/javascript/LICENSE
- name: Build host/javascript
working-directory: host/javascript
run: |
yarn install --frozen-lockfile
yarn build
# Publish
- name: Publish to NPM registry
working-directory: host/javascript
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_BOT_PAT }}
run: yarn publish --verbose --no-git-tag-version --access public --new-version ${{ needs.host-javascript-prepare.outputs.RELEASE_VERSION }} --tag ${{ needs.host-javascript-prepare.outputs.RELEASE_TAG }}
host-python-prepare:
name: Prepare Python Host
needs: [core]
if: ${{ inputs.host == 'python' || inputs.host == 'all' }}
runs-on: ubuntu-latest
steps:
# Setup
- uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install Python tools
run: python -m pip install build toml-cli
# Release version
- name: Resolve release level
id: release-level
run: scripts/release-level.sh ${{ inputs.release-level }} ${{ inputs.release-kind }} >>$GITHUB_OUTPUT
- name: Resolve release version
id: release-version
run: scripts/release-version.sh ./host/python/VERSION ${{ steps.release-level.outputs.RELEASE_LEVEL }} ${{ steps.release-level.outputs.RELEASE_PREID }} >>$GITHUB_OUTPUT
# Update version
- name: Update version in pyproject
working-directory: host/python
run: toml set --toml-path pyproject.toml project.version ${{ steps.release-version.outputs.RELEASE_VERSION }}
# Build
- uses: actions/download-artifact@v3
with:
name: core-wasm
path: host/python/src/one_sdk/assets
- name: Build host/python
working-directory: host/python
run: python -m build
# Changelog
- name: Update changelog
uses: superfaceai/release-changelog-action@v1
if: ${{ steps.release-level.outputs.RELEASE_TAG == 'latest' }}
with:
path-to-changelog: host/python/CHANGELOG.md
version: ${{ steps.release-version.outputs.RELEASE_VERSION }}
operation: release
# Commit release changes
- name: Git configuration
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions release workflow"
- name: Commit pyproject.toml, VERSION, CHANGELOG.md and create git tag
working-directory: host/python
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add pyproject.toml VERSION CHANGELOG.md
git commit -m "chore: release host/python ${{ steps.release-version.outputs.RELEASE_VERSION }}"
git tag "python-v${{ steps.release-version.outputs.RELEASE_VERSION }}"
git push origin
git push origin --tags
# Create GitHub Release
- name: Version for Changelog entry
id: get-changelog-version
env:
RELEASE_TAG: ${{ steps.release-level.outputs.RELEASE_TAG }}
VERSION: ${{ steps.release-version.outputs.RELEASE_VERSION }}
run: |
if [ "$RELEASE_TAG" = "latest" ]; then
echo VERSION="$VERSION"
else
echo VERSION="" # refers to unreleased section
fi
- name: Get release version changelog
id: get-changelog
uses: superfaceai/release-changelog-action@v1
with:
path-to-changelog: host/python/CHANGELOG.md
version: ${{ steps.get-changelog-version.outputs.VERSION }}
operation: read
- name: Update GitHub release documentation
uses: softprops/action-gh-release@v1
with:
tag_name: "python-v${{ steps.release-version.outputs.RELEASE_VERSION }}"
body: ${{ steps.get-changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
host-python-publish:
name: Publish Python Host
needs: [core, host-python-prepare]
if: ${{ !cancelled() && needs.host-python-prepare.result == 'success' }}
runs-on: ubuntu-latest
steps:
# Setup
- uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install Python tools
run: python -m pip install build toml-cli
# Build
- uses: actions/download-artifact@v3
with:
name: core-wasm
path: host/python/src/one_sdk/assets
- name: Copy LICENSE
run: cp LICENSE host/python/LICENSE
- name: Build host/python
working-directory: host/python
run: python -m build
# Publish
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: host/python/dist
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
trigger_daily:
name: Trigger daily build
needs: [host-javascript-publish, host-python-publish]
if: ${{ !cancelled() && (needs.host-javascript-publish.result == 'success' || needs.host-python-publish.result == 'success') }}
runs-on: ubuntu-latest
steps:
- name: Trigger Daily Test
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.GH_BOT_PAT }}
repository: superfaceai/superface-daily
event-type: on-demand-test