Skip to content

release

release #1083

Workflow file for this run

name: Release
on:
repository_dispatch:
types: [release]
workflow_dispatch:
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHECKOUT_REF: ${{ github.event.client_payload.ref }}
RELEASE_TYPE: ${{ github.event.client_payload.type }}
outputs:
published: ${{ steps.check-updates.outputs.published }}
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"
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 16
- name: Fetch git tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- 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: Publish to NPM
id: publish-npm
env:
NODE_AUTH_TOKEN: ${{secrets.HV_NPM_AUTOMATION_TOKEN}}
run: |
npm ci --include=dev
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
if [[ "${{ github.ref_name }}" == "master" ]]; then
npm run publish:release 2>&1 | tee publish_logs.txt
elif [[ "${{ github.ref_name }}" == "next"* ]]; then
npm run publish:next 2>&1 | tee publish_logs.txt
else
echo "Invalid event type: ${{ github.ref_name }}"
exit 1
fi
- name: Check if packages were updated
id: check-updates
run: |
if grep -q "lerna success published" publish_logs.txt; then
echo "New packages were published"
echo "published=true" >> "$GITHUB_OUTPUT"
elif grep -q "lerna Command failed" publish_logs.txt; then
echo "lerna Command failed"
exit 1
else
echo "No packages were updated"
echo "published=false" >> "$GITHUB_OUTPUT"
fi
publish-artifacts:
name: Publish Artifacts
needs: [publish]
if: needs.publish.outputs.published == 'true'
uses: ./.github/workflows/documentation.yml
secrets: inherit
with:
publish-folder: ${{ github.ref_name }}
notify-release:
name: Notify release
runs-on: ubuntu-latest
needs: [publish-artifacts]
env:
DOCUMENTATION_URL: https://${{ github.repository_owner }}.github.io/uikit/${{ github.ref_name }}/
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/slack-action@1.0
if: success()
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
with:
args: |
{
"channel": "ui-kit",
"attachments": [
{
"mrkdwn_in": ["text"],
"author_name": "New UI-Kit artifacts are available",
"title": "More details https://github.com/${{github.repository}}/releases",
"text": "${{env.SLACK_MESSAGE}}",
"footer": "${{env.DOCUMENTATION_URL}}"
}
]
}
security-scans:
name: Security Scans
needs: [publish-artifacts]
runs-on: ubuntu-latest
steps:
- name: Trigger Security Scans
# repo scope personal token is required to generate a dispatch event
run: |
curl -X POST \
https://api.github.com/repos/${{ github.repository }}/dispatches \
-H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' \
-d '{"event_type": "security"}'