Merge pull request #44 from qorelanguage/chore/import-fixes #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Beta release | |
on: | |
push: | |
branches: | |
- develop | |
jobs: | |
Publish-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
# Get time of PR event trigger | |
- name: Get current time | |
uses: josStorer/[email protected] | |
id: current_time | |
with: | |
format: YYYYMMDD-HH | |
utcOffset: '+01:00' | |
# Checkout repository | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.sha }} | |
# Get head commit message | |
- name: Print head git commit message | |
id: get_head_commit_message | |
run: echo "::set-output name=HEAD_COMMIT_MESSAGE::$(git show -s --format=%s)" | |
# Setup git user | |
- name: Setup git user | |
run: | | |
# setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
# Setup node | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: latest | |
# Install modules | |
- name: Installing modules | |
id: install_modules | |
run: | | |
rm -rf node_modules | |
yarn install | |
# Save release version | |
- name: Save release version to outputs | |
id: save_release_version | |
run: echo ::set-output name=version::$(node -pe "require('./package.json').version") | |
# Test the build | |
- name: Build test | |
id: build_test | |
run: yarn build:test | |
# Run unit tests | |
- name: Running tests | |
id: tests | |
run: yarn test | |
# Publish to NPM | |
- name: Publish to NPM | |
id: npm_publish | |
uses: JS-DevTools/npm-publish@v1 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
tag: beta | |
access: public | |
# Publish to chromatic | |
- name: Publish to Chromatic | |
env: | |
ENDPOINT_API: ${{ secrets.ENDPOINT_API}} | |
API_USER_NAME: ${{ secrets.API_USER_NAME}} | |
API_USER_PASS: ${{ secrets.API_USER_PASS }} | |
id: chromatic_publish | |
uses: chromaui/action@latest | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
exitZeroOnChanges: true | |
allowConsoleErrors: true | |
# Create new release | |
- name: Create a release | |
id: release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ steps.save_release_version.outputs.version }} | |
release_name: v${{ steps.save_release_version.outputs.version }} | |
body: v${{ steps.save_release_version.outputs.version }} | |
draft: false | |
prerelease: false | |
# Notify discord if all steps succeeded | |
- name: Discord notification | |
env: | |
DISCORD_WEBHOOK: ${{secrets.DISCORD_WEBHOOK}} | |
DISCORD_EMBEDS: '[{ "author": { "icon_url": "https://avatars.githubusercontent.com/${{ github.actor }}", "name": "${{ github.actor }}", "url": "https://github.com/${{github.actor}}" },"url": "https://github.com/${{github.repository}}/commit/${{github.sha}}","fields": [{ "name": "Commit Message", "value": "${{ steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE }}"},{ "name": "Repository", "value": "[${{github.event.repository.name}}](${{github.event.repository.clone_url}})", "inline": true },{ "name": "Branch", "value": "[${{github.ref_name}}](https://github.com/${{github.repository}}/pull/${{github.ref_name}})", "inline": true },{ "name": "Event", "value": "${{github.event_name}}", "inline": true },{ "name": "Author", "value": "[${{github.actor}}](https://github.com/${{github.actor}})", "inline": true },{ "name": "Job", "value": "${{github.job}}", "inline": true},{ "name": "", "value": "🤖 [Github Action](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id}}) 📙 [Documentation](${{ steps.chromatic_publish.outputs.storybookUrl }}) 🎨 [Chromatic Tests](${{ steps.chromatic_publish.outputs.buildUrl }})"}],"color":65280,"footer":{"text": "Published at ${{steps.current_time.outputs.readableTime}}"}}]' | |
DISCORD_AVATAR: 'https://raw.githubusercontent.com/qoretechnologies/qorus-toolkit/7d7988ad2be4388b1371f684278102d76f9ca5cb/public/q-symbol-small.png' | |
uses: Ilshidur/[email protected] | |
with: | |
args: ':white_check_mark: Release *v${{ steps.save_release_version.outputs.version }}* successfully created & published!' | |
if: success() | |
# Notify discord if all steps failed | |
- name: Discord notification | |
env: | |
DISCORD_WEBHOOK: ${{secrets.DISCORD_WEBHOOK}} | |
DISCORD_EMBEDS: '[{ "author": { "icon_url": "https://avatars.githubusercontent.com/${{ github.actor }}", "name": "${{ github.actor }}", "url": "https://github.com/${{github.actor}}" },"url": "https://github.com/${{github.repository}}/commit/${{github.sha}}","fields": [{ "name": "Commit Message", "value": "${{ steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE }}"},{ "name": "Repository", "value": "[${{github.event.repository.name}}](${{github.event.repository.clone_url}})", "inline": true },{ "name": "Branch", "value": "[${{github.ref_name}}](https://github.com/${{github.repository}}/pull/${{github.ref_name}})", "inline": true },{ "name": "Event", "value": "${{github.event_name}}", "inline": true },{ "name": "Author", "value": "[${{github.actor}}](https://github.com/${{github.actor}})", "inline": true },{ "name": "Job", "value": "${{github.job}}", "inline": true },{ "name": "", "value": "🤖 [Github Action](https://github.com/${{ github.repository}}/actions/runs/${{ github.run_id}})"}],"color":16711680,"footer":{"text": "Published at ${{steps.current_time.outputs.readableTime}}"}}]' | |
DISCORD_AVATAR: 'https://raw.githubusercontent.com/qoretechnologies/qorus-toolkit/7d7988ad2be4388b1371f684278102d76f9ca5cb/public/q-symbol-small.png' | |
uses: Ilshidur/[email protected] | |
with: | |
args: ':exclamation: Release *v${{ steps.save_release_version.outputs.version }}* failed!' | |
if: failure() |