Merge pull request #5 from roam-ai/0.1.0 #6
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 | |
on: | |
push: | |
branches: | |
- master # Change this to your default branch | |
jobs: | |
npm-publish: | |
name: npm-publish | |
runs-on: ubuntu-latest | |
steps: | |
# Publish to Node Package Manager | |
- name: Checkout Repo | |
uses: actions/checkout@main | |
- name: Setup Node.js (NPM) | |
uses: actions/setup-node@master | |
with: | |
node-version: '12.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Use cached node_modules | |
uses: actions/cache@master | |
with: | |
path: node_modules | |
key: nodeModules-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
nodeModules- | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
env: | |
CI: true | |
- name: Update Publish Config | |
run: sed -i 's^registry-url^registry.npmjs.org^' package.json | |
- name: Publish to NPM | |
run: npm publish --access public | |
env: | |
CI: true | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
gpr-publish: | |
name: gpr-publish | |
runs-on: ubuntu-latest | |
steps: | |
# Publish to GitHub Package Registry | |
- name: Checkout Repo | |
uses: actions/checkout@main | |
- name: Store lowercase actor name | |
run: | | |
echo 'actor_name<<EOF' >> $GITHUB_ENV | |
echo ${{ github.actor }} | tr "A-Z" "a-z" >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
- name: Store package name | |
run: | | |
echo 'package_name<<EOF' >> $GITHUB_ENV | |
grep -Po '"name": *\K"[^"]*"' package.json | grep -oP '"\K[^"\047]+(?=["\047])' >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
- name: Setup Node.js (GPR) | |
uses: actions/setup-node@master | |
with: | |
node-version: '12.x' | |
registry-url: https://npm.pkg.github.com/ | |
scope: '${{ env.actor_name }}' | |
- name: Use cached node_modules | |
uses: actions/cache@master | |
with: | |
path: node_modules | |
key: nodeModules-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
nodeModules- | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
env: | |
CI: true | |
- name: Update Package Name | |
run: | | |
sed -i 's,"name": "${{ env.package_name }}","name": "@${{ env.actor_name }}/${{ env.package_name }}",' package.json | |
cat package.json | |
- name: Update Publish Config | |
run: | | |
sed -i 's^registry-url^npm.pkg.github.com/@${{ env.actor_name }}^' package.json | |
cat package.json | |
- name: Publish to GitHub Package Registry | |
run: npm publish --access public | |
env: | |
CI: true | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |