Skip to content

Fix verify-gpr npm config and bump version to 1.0.2 #8

Fix verify-gpr npm config and bump version to 1.0.2

Fix verify-gpr npm config and bump version to 1.0.2 #8

name: GitHub Packages
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
# ============================================
# PUBLISH TO GITHUB PACKAGES
# ============================================
publish-gpr:
name: Publish to GitHub Packages
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./cloudsync-cli
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://npm.pkg.github.com'
scope: '@tech4file'
cache: 'npm'
cache-dependency-path: cloudsync-cli/package-lock.json
- name: Configure npm for GitHub Packages
run: |
cat <<EOF > ~/.npmrc
@tech4file:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=\${NODE_AUTH_TOKEN}
EOF
- name: Get version
id: version
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
else
echo "VERSION=1.0.0" >> $GITHUB_OUTPUT
fi
- name: Update package name for GitHub Packages
run: |
npm pkg set name="@tech4file/cloudsync-cli"
npm pkg set publishConfig.registry="https://npm.pkg.github.com"
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Publish to GitHub Packages
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ============================================
# VERIFY PUBLISHED PACKAGE
# ============================================
verify-gpr:
name: Verify Published Package
runs-on: ubuntu-latest
needs: [publish-gpr]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://npm.pkg.github.com'
scope: '@tech4file'
- name: Configure npm for GitHub Packages
run: |
cat <<EOF > ~/.npmrc
@tech4file:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=\${NODE_AUTH_TOKEN}
EOF
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install published package
run: |
sleep 15
npm install -g @tech4file/cloudsync-cli
cloudsync --version
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test installed package
run: |
cloudsync doctor
cloudsync --help | head -20