Skip to content

feat: Testing with jq #13

feat: Testing with jq

feat: Testing with jq #13

Workflow file for this run

name: Publish Package
on:
push:
branches: [main]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://npm.pkg.github.com/' # this is important for the publishing step
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create Beta Tag
id: tag
run: |
set -e
# Get current version
current_version=$(node -p "require('./package.json').version")
COMMIT_SHA=$(git rev-parse --short HEAD)
# Generate a beta tag using GitHub run number
# beta_tag="beta.${GITHUB_RUN_ID}"
beta_tag="dev.${COMMIT_SHA}-${GITHUB_RUN_ID}"
# Create full version with beta tag
base_version=$(echo $current_version | cut -f1,2 -d.)
patch_version=$(echo $current_version | cut -f3 -d.)
new_patch_version=$((patch_version + 1))
new_version="${base_version}.${new_patch_version}-${beta_tag}"
# Create an annotated tag
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git tag -a "$new_version" -m "Release version $new_version"
# Set output for later steps
echo "::set-output name=tag_name::$new_version"
- name: Push Beta Tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git push origin "${{ steps.tag.outputs.tag_name }}"
# - name: Configure .npmrc
# run: |
# echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
- name: Install Dependencies
run: npm install
- name: Update package.json with organization scope
run: |
ORG_NAME="@amikos-tech"
PACKAGE_NAME=$(jq -r '.name' package.json)
jq --arg org "$ORG_NAME" --arg name "$PACKAGE_NAME" '.name = "\($org)/\($name)"' package.json > tmp.$$.json && mv tmp.$$.json package.json
- name: Publish Package
run: |
set -e
npm version "${{ steps.tag.outputs.tag_name }}" --no-git-tag-version --tag alpha
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}