Pine Icons Production Release #7
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: "Pine Icons Production Release" | |
on: | |
workflow_call: | |
inputs: | |
preid: | |
description: Which prerelease id should be used? This is only needed when a version is "prepatch", "preminor", "premajor", or "prerelease". | |
type: string | |
default: '' | |
ref: | |
type: string | |
description: The branch name, tag, or SHA to be checked out. This can also be left blank. | |
default: '' | |
tag: | |
type: 'string' | |
required: true | |
description: Which npm tag should this be published to | |
version: | |
type: string | |
description: Which version should be published? | |
workflow_dispatch: | |
inputs: | |
preid: | |
type: choice | |
description: Which prerelease id should be used? This is only needed when a version is "prepatch", "preminor", "premajor", or "prerelease". | |
options: | |
- '' | |
- alpha | |
- beta | |
- rc | |
- next | |
ref: | |
type: string | |
description: The branch name, tag, or SHA to be checked out. This can also be left blank. | |
default: '' | |
tag: | |
type: choice | |
required: true | |
description: Which npm tag should this be published to | |
options: | |
- latest | |
- next | |
- dev | |
version: | |
type: choice | |
description: Which version should be published? | |
options: | |
- '' | |
- patch | |
- minor | |
- major | |
- prepatch | |
- preminor | |
- premajor | |
- prerelease | |
jobs: | |
export-icons: | |
uses: ./.github/workflows/icon-export.yml | |
with: | |
preid: ${{ inputs.preid || '' }} | |
ref: ${{ inputs.ref || 'main' }} | |
tag: ${{ inputs.tag || 'nightly' }} | |
version: ${{ inputs.version || '' }} | |
secrets: inherit | |
release-changes: | |
runs-on: ubuntu-latest | |
needs: export-icons | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get latest | |
run: git pull | |
shell: bash | |
- name: Install Dependencies | |
run: npm ci --ignore-scripts | |
shell: bash | |
- name: Configure user | |
run: | | |
git config user.name "DSS Automation Bot" | |
git config user.email "[email protected]" | |
- name: Prepare NPM Token | |
run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} >> .npmrc | |
shell: bash | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Build | |
run: npx nx run @pine-ds/icons:build | |
shell: bash | |
- name: Release | |
if: inputs.version == '' | |
run: npx nx release --yes | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Release using Input Version | |
if: inputs.version != '' | |
run: npx nx release ${{inputs.version}} --yes | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
send-slack-notification: | |
runs-on: ubuntu-latest | |
needs: release-changes | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get latest | |
run: git pull | |
shell: bash | |
- name: Setup ENV Vars | |
run: | | |
echo 'PACKAGE_JSON<<EOF' >> $GITHUB_ENV | |
cat ./package.json >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
echo "COMMIT_MESSAGE=$(git log --pretty=format:%s -n 1 HEAD~)" >> $GITHUB_ENV | |
- name: Send Slack Notification | |
uses: slackapi/[email protected] | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
DATE: ${{ env.CURRENT_DATE }} | |
RELEASE_URL: "${{ format('https://github.com/{0}/releases/tag/v{1}', github.repository, fromJSON(env.PACKAGE_JSON).version) }}" | |
CHANGELOG_URL: "${{ format('https://pine-icons.netlify.app/changelogs/{0}-changelog.html', env.CURRENT_DATE) }}" | |
VERSION: ${{ fromJson(env.PACKAGE_JSON).version }} | |
COMMIT_MESSAGE: ${{ env.COMMIT_MESSAGE }} | |
with: | |
channel-id: ${{ vars.SLACK_CHANNEL_NAME }} | |
payload-file-path: "./.github/workflows/slack_payloads/release-info.json" |