Skip to content

final check

final check #34

name: Generate and Publish Client Libraries
on:
push:
branches: [main]
jobs:
generate-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "16" # Or your preferred Node.js version
- name: Install Dependencies
run: npm install
# - name: Validate Schemas
# run: node validate-schemas.js # Assuming you have a validation script
- name: Generate TypeScript Client
run: node ./clients/typescript/generate.js
- name: Set Git User Information
run: |
git config --global user.email "${{ secrets.SCHEMACHER_GIT_EMAIL }}"
git config --global user.name "${{ secrets.SCHEMACHER_GIT_NAME }}"
# - name: Add and Commit Generated Files
# run: |
# git add .
# git commit -m "Generated TypeScript client files"
# - name: Publish TypeScript Client (if on main branch)
# if: github.ref == 'refs/heads/main'
# run: |
# cd clients/typescript
# npm version patch # Increment version (optional)
# npm publish --access public
- name: Authenticate with GitHub
env:
GITHUB_TOKEN: ${{ secrets.G_TOKEN }}
run: |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/eyeamkd/schemacher.git
- name: Generate and Publish TypeScript Client
run: |
cd clients/typescript
node generate.js # Generate the files (including package.json)
cd ../../package
git add . # Add any new/changed files to git
git commit -m "Generated TypeScript client files" # Commit changes
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
npm whoami # Verify that you're logged in (optional)
if npm view @eyeamkd/user-types version >/dev/null 2>&1; then
npm version patch
npm publish --access public # Publish inside the if block
else
npm publish --access public # Publish initial version if it doesn't exist
fi
rm -rf package
git add .
git commit -m "Generated TypeScript client files" # Commit changes
git push
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}