Release to GitHub and NPM #757
Workflow file for this run
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: | |
- 'next' | |
pull_request: | |
types: [opened, synchronize] | |
branches: | |
- 'next' | |
env: | |
HUSKY: 0 | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
container: | |
image: kevinshahfws/node-c:3.0 | |
steps: | |
# Checkout/install project | |
- 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 | |
# Set NPM_DIST_TAGS and DOCS_TAG if applicable based on branch | |
- name: Set feature branch tags | |
if: github.ref_name != 'main' && github.ref_name != 'next' && github.ref_name != 'next-major' && 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.ref_name != 'next-major' && 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: Set file permissions | |
run: | | |
chmod -R 755 ./ | |
chown -R $(id -u):$(id -g) ./ | |
- name: Build artifacts for feature branches | |
if: github.ref_name != 'main' && github.ref_name != 'next' && github.ref_name != 'next-major' | |
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: Get version from package.json | |
run: | | |
RELEASE_VERSION=$(node -p "require('./package.json').version") | |
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV | |
echo "build_cpp_source=true" >> $GITHUB_ENV | |
- name: Set cpp build source Condition | |
if: steps.check_build.outputs.files_exists == 'false' || (github.ref_name == 'main' && github.event_name != 'pull_request' && github.event_name != 'workflow_dispatch') | |
run: echo "build_cpp_source=false" >> $GITHUB_ENV | |
- name: Clone and Install Thunder | |
if: env.build_cpp_source == 'true' | |
id: install_thunder | |
run: | | |
.github/workflows/utils.sh cloneAndInstallThunder | |
- name: Generate native sdk source | |
if: env.build_cpp_source == 'true' | |
run: | | |
.github/workflows/utils.sh generateSource | |
- name: Build Core SDK CPP | |
if: env.build_cpp_source == 'true' | |
id: build_core_cpp | |
run: | | |
.github/workflows/utils.sh buildCoreCPPSDK $RELEASE_VERSION | |
# - name: Build Manage SDK CPP | |
# if: env.build_cpp_source == 'true' | |
# id: build_manage_cpp | |
# run: | | |
# .github/workflows/utils.sh buildManageCPPSDK $RELEASE_VERSION | |
# - name: Build Discovery SDK CPP | |
# if: env.build_cpp_source == 'true' | |
# id: build_discovery_cpp | |
# run: | | |
# .github/workflows/utils.sh buildDiscoveryCPPSDK $RELEASE_VERSION |