Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 55 additions & 8 deletions .github/workflows/publish-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,43 @@ on:
- 'api/**'

permissions:
contents: read
contents: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Bump minor version
working-directory: ./api
run: npm version minor --no-git-tag-version

- name: Read version
id: version
run: |
VERSION=$(jq -r '.version' api/package.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Releasing version: $VERSION"

- name: Check if already released
run: |
TAG="jfrog-workers/${{ steps.version.outputs.version }}"
if git ls-remote --tags origin "refs/tags/$TAG" | grep -q .; then
echo "Tag '$TAG' already exists — version ${{ steps.version.outputs.version }} has already been released."
exit 1
fi

- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Create release branch
run: git checkout -b "jfrog-workers-${{ steps.version.outputs.version }}"

- name: Setup Node.js
uses: actions/setup-node@v4
Expand All @@ -30,23 +59,23 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_EMAIL: [email protected]
run: |
echo "Creating npmrc for publish"
cat > .npmrc << EOF
always-auth=true
email=${NPM_EMAIL}
registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
EOF
cat .npmrc
echo "Creating npmrc done"


- name: Install dependencies
working-directory: ./api
run: npm install --no-progress

- name: Update minor version
working-directory: ./api
run: npm version minor --no-git-tag-version
- name: Commit version bump
run: |
NEW_VERSION=$(jq -r '.version' api/package.json)
git add api/package.json
git add api/package-lock.json 2>/dev/null || true
git commit -m "chore: bump version to ${NEW_VERSION} [skip ci]"

- name: Build
working-directory: ./api
Expand All @@ -58,3 +87,21 @@ jobs:
echo "Publishing API npm package"
npm publish
echo "Publishing API npm package done"

- name: Push release branch
run: git push origin "jfrog-workers-${{ steps.version.outputs.version }}"

- name: Create and push release tag
run: |
TAG="jfrog-workers/${{ steps.version.outputs.version }}"
git tag "$TAG"
git push origin "$TAG"
echo "Created tag: $TAG"

- name: Merge to main
run: |
BRANCH="jfrog-workers-${{ steps.version.outputs.version }}"
git fetch origin main
git checkout main
git merge --no-ff "$BRANCH" -m "chore: merge release ${BRANCH} into main [skip ci]"
git push origin main