chore(cli): ignore git errors when uploading (#1076) #1033
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: Publish SDK & CLI | |
on: | |
push: | |
branches: | |
- main | |
- release | |
- v1 | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
ref: ${{ github.event.inputs.commit }} | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: 'pnpm' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Set NPM variables | |
id: npm | |
run: | | |
BRANCH=${GITHUB_REF##*/} | |
DIST_TAG=rc | |
if [[ $BRANCH == "release" ]]; then | |
DIST_TAG=latest | |
fi | |
echo "dist_tag=${DIST_TAG}" >> $GITHUB_OUTPUT | |
pnpm config list | |
- name: Install | |
run: pnpm install | |
- name: Build SDK & CLI | |
run: pnpm --filter "./packages/*..." build | |
- name: SDK Semantic Release | |
id: semantic | |
uses: cycjimmy/semantic-release-action@v4 | |
with: | |
semantic_version: 24.0.0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
- name: SDK Release Summary | |
if: steps.semantic.outputs.new_release_published == 'true' | |
run: | | |
echo "### New SDK version v${{ steps.semantic.outputs.new_release_version }} cut" >> $GITHUB_STEP_SUMMARY | |
echo "commit: ${GITHUB_SHA}, branch/tag: ${GITHUB_REF}" >> $GITHUB_STEP_SUMMARY | |
echo "${{ steps.semantic.outputs.new_release_notes }}" >> $GITHUB_STEP_SUMMARY | |
env: | |
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
- name: Clean runtime dependencies | |
run: | | |
# Dependencies are bundled. | |
pnpm json -I -f package.json -e "this.dependencies={}" | |
working-directory: packages/runtime | |
- name: SDK NPM Publish | |
if: steps.semantic.outputs.new_release_published == 'true' | |
run: | | |
./scripts/update-version.sh @sentio/sdk... ${{ steps.semantic.outputs.new_release_version }} | |
pnpm publish --filter "@sentio/sdk..." --no-git-checks --tag ${{ steps.npm.outputs.dist_tag }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: report error | |
if: steps.semantic.outputs.new_release_published == 'false' | |
run: | | |
echo "### No SDK version cut" >> $GITHUB_STEP_SUMMARY | |
echo "Check Semantic Release output for details" | |
- name: Clean peerDependencies & templates' node_modules | |
run: | | |
# Dependencies are bundled. | |
pnpm json -I -f package.json -e "this.dependencies=Object.fromEntries(Object.entries(this.dependencies).filter((entry) => ['@sentio/graph-cli', 'dotenv', 'tsup', 'tsx'].includes(entry['0'])))" | |
# PeerDeps only for development with pnpm | |
# templates' node_modules shouldn't go into registry | |
pnpm json -I -f package.json -e "this.peerDependencies={}" | |
rm -rf templates/*/node_modules | |
working-directory: packages/cli | |
- name: CLI Semantic Release | |
id: semantic_cli | |
uses: cycjimmy/semantic-release-action@v4 | |
with: | |
working_directory: packages/cli | |
semantic_version: 24 | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
- name: CLI Release Summary | |
if: steps.semantic_cli.outputs.new_release_published == 'true' | |
run: | | |
echo "### New CLI version v${{ steps.semantic_cli.outputs.new_release_version }} cut" >> $GITHUB_STEP_SUMMARY | |
echo "commit: ${GITHUB_SHA}, branch/tag: ${GITHUB_REF}" >> $GITHUB_STEP_SUMMARY | |
echo "${{ steps.semantic_cli.outputs.new_release_notes }}" >> $GITHUB_STEP_SUMMARY | |
env: | |
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
- name: CLI NPM Publish | |
if: steps.semantic_cli.outputs.new_release_published == 'true' | |
run: | | |
./scripts/update-version.sh sentio-cli... ${{ steps.semantic_cli.outputs.new_release_version }} | |
pnpm publish --filter "sentio-cli..." --no-git-checks --tag ${{ steps.npm.outputs.dist_tag }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: report error | |
if: steps.semantic_cli.outputs.new_release_published == 'false' | |
run: | | |
echo "### No CLI version cut" >> $GITHUB_STEP_SUMMARY | |
echo "Check Semantic Release output for details" | |
- name: Prepare sdk-bundle | |
if: steps.semantic.outputs.new_release_published == 'true' | |
run: | | |
pnpm build:bundle | |
pnpm json -I -f package.json -e "this.dependencies=Object.fromEntries(Object.entries(this.dependencies).filter((entry) => ['@sentio/runtime'].includes(entry['0'])))" | |
pnpm json -I -f package.json -e 'this.name="@sentio/sdk-bundle"; this.scripts={}; this.peerDependencies={}; this.devDependencies={}; this.files = ["{lib,assets}"]' | |
working-directory: packages/sdk | |
- name: sdk-bundle NPM Publish | |
if: steps.semantic.outputs.new_release_published == 'true' | |
run: | | |
pnpm publish --filter "@sentio/sdk-bundle" --no-git-checks --tag ${{ steps.npm.outputs.dist_tag }} --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: action NPM Publish | |
if: steps.semantic.outputs.new_release_published == 'true' | |
run: | | |
./scripts/update-version.sh @sentio/action ${{ steps.semantic.outputs.new_release_version }} | |
pnpm publish --filter "@sentio/action" --no-git-checks --tag ${{ steps.npm.outputs.dist_tag }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Clean Github Release for RC | |
if: ${{ contains(steps.semantic.outputs.new_release_version, '-rc.') == false }} | |
run: ./scripts/clean-rc-releases.sh | |
env: | |
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} |