Publish #92
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 | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 4 * * *' | |
push: | |
tags: | |
- v*.*.* | |
jobs: | |
publish: | |
name: Publish | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write # needed for provenance data generation | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: https://registry.npmjs.org/ | |
- name: Install dependencies | |
run: npm install --legacy-peer-deps | |
shell: bash | |
- name: Print Environment Info | |
run: npx nx report | |
shell: bash | |
- name: Run command and capture output | |
id: get_output | |
run: | | |
output=$(npx nx show projects --affected -t nx-release-publish --sep=,) | |
echo "Command Output: $output" | |
echo "result=$output" >> $GITHUB_OUTPUT | |
- name: Version | |
if: steps.get_output.outputs.result != '' | |
run: npx nx release version minor -p ${{ steps.get_output.outputs.result }} | |
shell: bash | |
- name: Build projects | |
if: steps.get_output.outputs.result != '' | |
run: npx nx run-many --target=build --projects=${{ steps.get_output.outputs.result }} | |
shell: bash | |
- name: Publish packages | |
if: steps.get_output.outputs.result != '' | |
run: npx nx release publish -p ${{ steps.get_output.outputs.result }} | |
shell: bash | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} | |
NPM_CONFIG_PROVENANCE: true | |
- name: Setup Git | |
if: steps.get_output.outputs.result != '' | |
run: | | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor }}@users.noreply.github.com" | |
- name: Commit changes | |
if: steps.get_output.outputs.result != '' | |
run: | | |
git add . | |
[[ $(git status --porcelain) ]] && git commit -m "build: publish packages" || echo "nothing to commit" | |
- name: Push changes | |
if: steps.get_output.outputs.result != '' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |
- name: Fallback if empty | |
if: steps.get_output.outputs.result == '' | |
run: | | |
echo "No project to publish." |