Skip to content

v3.3.8

v3.3.8 #16

Workflow file for this run

# This action handles the automatic publishing of new releases
name: Release
on:
release:
types: [published]
jobs:
publish-package:
name: Publish package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v2
with:
node-version: 16
- run: npm ci
# We do not create a commit with the update package version
# Therefore the package.*.json in the repository will always have out-of-sync versions
- name: Set version in code (update package.json)
run: npm --no-git-tag-version version ${{ github.event.release.tag_name }}
- name: Build library
run: npm run build
env:
BUILD_VERSION: ${{ github.event.release.tag_name }}
- name: Publish library
run: npm run publish
env:
NPM_PUBLISH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish build assets to release
uses: softprops/action-gh-release@v1
with:
files: |
./dist/widgets.umd.js
./dist/widgets.modern.js
./dist/widgets.m.js
./dist/widgets.js
./dist/widgets.css
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Send changelog to Slack
slack-notification:
name: Publish changelog to Slack
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# Fetch the latest commit, only
fetch-depth: 1
- name: Get release notes
id: release-notes
run: |
# Retrieve the release notes from the repository itself to prevent release notes from being truncated
# cf. https://github.community/t/set-output-truncates-multiline-strings/16852
RELEASE_NOTES="$(cat $GITHUB_EVENT_PATH | jq -r .release.body)"
RELEASE_NOTES="${RELEASE_NOTES//'%'/'%25'}"
RELEASE_NOTES="${RELEASE_NOTES//$'\n'/'%0A'}"
RELEASE_NOTES="${RELEASE_NOTES//$'\r'/'%0D'}"
# Add URLs to GitHub pull requests
PULL_REQUEST_URL_START=${{ github.event.repository.html_url }}/pull/
ESCAPED_PULL_REQUEST_URL_START=$(printf '%s\n' "$PULL_REQUEST_URL_START" | sed -e 's/[\/&]/\\&/g')
RELEASE_NOTES=$(echo $RELEASE_NOTES | sed -E "s/#([0-9]+)/[#\1](${ESCAPED_PULL_REQUEST_URL_START}\1)/g")
# Add URLs to GitHub profiles
PROFILE_URL_START=${{ github.server_url }}/
ESCAPED_PROFILE_URL_START=$(printf '%s\n' "$PROFILE_URL_START" | sed -e 's/[\/&]/\\&/g')
RELEASE_NOTES=$(echo $RELEASE_NOTES | sed -E "s/@([[:alnum:]-]+)/[@\1](${ESCAPED_PROFILE_URL_START}\1)/g")
echo ::set-output name=RELEASE_NOTES::"$RELEASE_NOTES"
- name: Use Slack markdown
uses: LoveToKnow/slackify-markdown-action@v1.0.0
id: slack-markdown-release-notes
with:
text: |
New release of `alma/widgets` published, **[${{ github.event.release.name }}](${{
github.event.release.html_url }})**:
${{ steps.release-notes.outputs.RELEASE_NOTES }}
- name: Send changelog to Slack
uses: slackapi/slack-github-action@v1.16.0
with:
# Channel `#alma_changelog`
channel-id: 'CR9C57YM6'
slack-message: ${{ steps.slack-markdown-release-notes.outputs.text }}
payload: |
{
"username": "${{ github.event.sender.login }}",
"icon_url": "${{ github.event.sender.avatar_url }}"
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_RELEASE_CHANGELOG_BOT_TOKEN }}