Skip to content

Restructured workspace layout, moved workflows to root, and added roo… #1

Restructured workspace layout, moved workflows to root, and added roo…

Restructured workspace layout, moved workflows to root, and added roo… #1

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=$(node -p \"require('./package.json').version\")" >> $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: Install published package
run: |
npm install -g @tech4file/cloudsync-cli
cloudsync --version
- name: Test installed package
run: |
cloudsync doctor
cloudsync --help | head -20