SWC-7076 - Update Sage ToS #3062
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: 'NPM Publish and GitHub tag' | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: [main] | |
jobs: | |
tag-and-publish: | |
strategy: | |
matrix: | |
publishablePackage: | |
[ | |
synapse-react-client, | |
markdown-it-synapse, | |
markdown-it-synapse-table, | |
'@sage-bionetworks/markdown-it-container', | |
'@sage-bionetworks/synapse-types', | |
] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/pnpm-setup-action | |
- name: Get package path | |
id: package-path | |
run: | | |
packagePath=$(pnpm nx show project ${{ matrix.publishablePackage }} --json | jq -r '.sourceRoot') | |
echo "packagePath=${packagePath}" >> "$GITHUB_OUTPUT" | |
# Check if the package version changed | |
- id: package-version-check | |
uses: EndBug/version-check@v2 | |
with: | |
diff-search: true | |
file-name: './${{ steps.package-path.outputs.packagePath }}/package.json' | |
# Build the package to publish | |
- name: Build package | |
run: pnpm nx run ${{ matrix.publishablePackage }}:build | |
# If the package version changed, and the build succeeded, create the tag using the output of the previous step. | |
- name: Create tag | |
uses: actions/github-script@v7 | |
if: github.event_name == 'push' && steps.package-version-check.outputs.changed == 'true' | |
with: | |
github-token: ${{ github.token }} | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: "refs/tags/${{ matrix.publishablePackage }}/v${{ steps.package-version-check.outputs.version }}", | |
sha: context.sha | |
}) | |
- name: Publish to NPM # or simulate the publish for PRs | |
run: pnpm publish --access public ${{ ((github.event_name == 'pull_request' || steps.package-version-check.outputs.changed == 'false') && '--dry-run --no-git-checks') || '' }} | |
working-directory: './${{ steps.package-path.outputs.packagePath }}' | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |