fix: Modified account:uid to SHOULD (#224) #434
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: Release to GitHub and NPM | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- 'main' | |
- 'next' | |
- 'next-major' | |
- 'proposed' | |
pull_request: | |
types: [opened, synchronize] | |
branches: | |
- 'next' | |
- 'proposed' | |
env: | |
HUSKY: 0 | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
repo-token: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} | |
persist-credentials: false | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 'lts/*' | |
- name: Set up NPM token | |
env: | |
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} # <-- allow npm publish for each workspace | |
run: 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc' | |
- name: Install dependencies | |
run: npm ci | |
- name: Set main tags | |
if: github.ref_name == 'main' && github.event_name != 'pull_request' | |
run: | | |
echo "NPM_DIST_TAG=latest" >> $GITHUB_ENV | |
echo "DOCS_TAG=latest" >> $GITHUB_ENV | |
- name: Set next tags | |
if: github.ref_name == 'next' && github.event_name != 'pull_request' | |
run: | | |
echo "NPM_DIST_TAG=next" >> $GITHUB_ENV | |
echo "DOCS_TAG=next" >> $GITHUB_ENV | |
- name: Set feature branch tags | |
if: github.ref_name != 'main' && github.ref_name != 'next' && github.event_name != 'pull_request' | |
run: | | |
echo "NPM_DIST_TAG=test" >> $GITHUB_ENV | |
echo "FEATURE_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV | |
- name: Set PR tags | |
if: github.ref_name != 'main' && github.ref_name != 'next' && github.event_name == 'pull_request' | |
run: | | |
echo "NPM_DIST_TAG=test" >> $GITHUB_ENV | |
echo "DOCS_TAG=pr-$(node ./src/js/version.mjs branch-to-prerelease ${{ github.head_ref }})" >> $GITHUB_ENV | |
echo "FEATURE_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV | |
- name: Release mono-artifact to GitHub | |
if: (github.ref_name != 'main' && github.event_name != 'pull_request') || github.event_name == 'workflow_dispatch' | |
env: | |
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches | |
run: npx semantic-release | |
- name: Dry-run mono-artifact | |
if: (github.ref_name == 'main' && github.event_name != 'workflow_dispatch') || github.event_name == 'pull_request' | |
env: | |
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches | |
run: npx semantic-release --dry-run | |
- name: Build artifacts for feature branches | |
if: github.ref_name != 'main' && github.ref_name != 'next' | |
run: | | |
PRERELEASE=$(node ./src/js/version.mjs branch-to-prerelease $FEATURE_BRANCH) | |
node ./src/js/version.mjs latest-prerelease $PRERELEASE | |
npm version prerelease --preid $PRERELEASE --git-tag-version false | |
npm version prerelease --preid $PRERELEASE --workspaces --git-tag-version false | |
npm run dist | |
- name: Check if semantic-release created a build | |
id: check_build | |
uses: andstor/file-existence-action@v2 | |
with: | |
files: "./src/sdks/core/dist/lib/firebolt.mjs" | |
- name: Release Firebolt SDKs to NPM | |
if: steps.check_build.outputs.files_exists == 'true' && github.event_name != 'pull_request' && (github.ref_name != 'main' || github.event_name == 'workflow_dispatch') | |
env: | |
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} # <-- Allows semantic-release to publish to npm without 2 factor auth. | |
run: | | |
npm --version | |
echo "NPM DIST TAG :: " $NPM_DIST_TAG | |
npm publish --tag $NPM_DIST_TAG --workspaces | |
- name: Dry-run Firebolt SDKs to NPM | |
if: steps.check_build.outputs.files_exists == 'true' && (github.ref_name == 'main' && github.event_name != 'workflow_dispatch') | |
env: | |
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} # <-- Allows semantic-release to publish to npm without 2 factor auth. | |
run: npm publish --tag $NPM_DIST_TAG --workspaces --dry-run | |
- name: Checkout firebolt GitHub.io repository | |
if: steps.check_build.outputs.files_exists == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches | |
run: | | |
cd /tmp | |
git clone https://rdkcentral:[email protected]/rdkcentral/firebolt.git ./firebolt-docs | |
- name: Release docs to GitHub.io | |
if: steps.check_build.outputs.files_exists == 'true' && (github.ref_name == 'main' || github.ref_name == 'next' || github.event_name == 'pull_request') | |
env: | |
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches | |
run: | | |
npm run publish:docs /tmp/firebolt-docs $DOCS_TAG | |
cd /tmp/firebolt-docs | |
git config --global user.email "[email protected]" | |
git config --global user.name "Your Name" | |
git add --all | |
git diff-index --quiet HEAD || git commit -m "chore: Publish $DOCS_TAG" | |
git push |