Skip to content

Release

Release #1163

Workflow file for this run

name: Release
on:
schedule:
- cron: "0 5 * * 1,4" # at 05:00 on monday,thursday
workflow_dispatch:
jobs:
tests:
name: Tests
uses: ./.github/workflows/tests.yml
secrets: inherit
visual-tests:
name: Visual Tests
uses: ./.github/workflows/tests-visual.yml
secrets: inherit
publish:
name: Publish Packages
needs: [tests, visual-tests]
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHECKOUT_REF: ${{ github.event.client_payload.ref }}
RELEASE_TYPE: ${{ github.event.client_payload.type }}
NPM_CONFIG_PROVENANCE: true
outputs:
SLACK_MESSAGE: ${{ steps.slackMessage.outputs.SLACK_MESSAGE }}
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Pulls all commits (needed for semantic release to correctly version)
# See https://github.com/semantic-release/semantic-release/issues/1526
fetch-depth: "0"
fetch-tags: true
- name: Publish Setup
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
- name: Publish to NPM
id: publish-npm
env:
NODE_AUTH_TOKEN: ${{secrets.HV_NPM_AUTOMATION_TOKEN}}
run: |
VERSION=v$(npm pkg get version -ws | sed -n 's/.*uikit-react-core": "\(.*\)".*/\1/p')
echo "CURRENT_VERSION=$VERSION" >> "$GITHUB_ENV"
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm run publish 2>&1 | tee publish_logs.txt
- name: Check if packages were updated
run: |
if grep -q "lerna success published" publish_logs.txt; then
echo "New packages were published successfully"
elif grep -q "lerna Command failed" publish_logs.txt; then
echo "lerna Command failed"
exit 1
else
echo "No packages were updated - skipping release"
exit 1
fi
- name: Set NEW_VERSION
id: version
# Outputs the NEW_VERSION if there is one, or exits otherwise
# We only tag+publish+notify if there a new core package version
run: |
VERSION=v$(npm pkg get version -ws | sed -n 's/.*uikit-react-core": "\(.*\)".*/\1/p')
if [ "$CURRENT_VERSION" = "$VERSION" ]; then
echo "No new uikit-react-core version to release. Exiting"
exit 1
fi
echo "NEW_VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Tag Release
run: |
git tag -a $NEW_VERSION -m "Version $NEW_VERSION"
git push origin $NEW_VERSION
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm i --no-save [email protected]
npx changelogithub --from $CURRENT_VERSION --to $NEW_VERSION
- name: Set SLACK_MESSAGE
id: slackMessage
run: |
echo "SLACK_MESSAGE=$(.github/scripts/changelog.js $CURRENT_VERSION $NEW_VERSION)" >> $GITHUB_OUTPUT
publish-documentation:
name: Publish Documentation
needs: [publish]
uses: ./.github/workflows/documentation.yml
secrets: inherit
with:
publish-folder: ${{ github.ref_name }}
security-scans:
name: Security Scans
needs: [publish]
uses: ./.github/workflows/security.yml
secrets: inherit
notify-release:
name: Notify release
runs-on: ubuntu-latest
needs: [publish]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Send Slack message
uses: slackapi/[email protected]
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }}
with:
channel-id: "ui-kit"
payload: |
{ "blocks": ${{ needs.publish.outputs.SLACK_MESSAGE }} }