Skip to content

Release

Release #1148

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:
NEW_VERSION: ${{ steps.version.outputs.NEW_VERSION }}
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"
elif grep -q "lerna Command failed" publish_logs.txt; then
echo "lerna Command failed"
exit 1
else
echo "No packages were updated"
exit 1
fi
- name: Set NEW_VERSION
id: version
# Outputs the NEW_VERSION if there is one, or empty otherwise
run: |
VERSION=v$(npm pkg get version -ws | sed -n 's/.*uikit-react-core": "\(.*\)".*/\1/p')
echo "NEW_VERSION=$( [ "$CURRENT_VERSION" = "$VERSION" ] && echo "" || echo "$VERSION" )" >> "$GITHUB_OUTPUT"
- name: Tag Release
if: steps.version.outputs.NEW_VERSION
env:
VERSION: ${{steps.version.outputs.NEW_VERSION}}
run: |
git tag -a $VERSION -m "Version $VERSION"
git push origin $VERSION
- name: Create GitHub Release
if: steps.version.outputs.NEW_VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{steps.version.outputs.NEW_VERSION}}
run: npx [email protected] --from $CURRENT_VERSION --to $VERSION
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]
if: needs.publish.outputs.NEW_VERSION
env:
DOCUMENTATION_URL: https://${{ github.repository_owner }}.github.io/uikit/${{ github.ref_name }}/
VERSION: ${{ needs.publish.outputs.NEW_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Releases Commit Message
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const branch = await github.repos.getBranch({
owner: context.repo.owner,
repo: context.repo.repo,
branch: "${{ github.ref_name }}"
})
const commitMessage = branch.data.commit.commit.message
const slackMessage = commitMessage.replace('chore(release): publish', '')
.replace(/\n/g, "\\n")
.replace(/\r/g, "\\r")
.replace(/\t/g, "\\t")
.replace(/\f/g, "\\f")
core.exportVariable("SLACK_MESSAGE", slackMessage)
- name: Notify release
uses: hbfernandes/[email protected]
if: success()
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
with:
args: |
{
"channel": "ui-kit",
"attachments": [
{
"mrkdwn_in": ["text"],
"author_name": "New UI-Kit Release is available",
"title": "https://github.com/${{github.repository}}/releases/${{env.VERSION}}",
"text": "${{env.SLACK_MESSAGE}}",
"footer": "${{env.DOCUMENTATION_URL}}"
}
]
}