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
14 changes: 13 additions & 1 deletion .github/workflows/publish-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,33 @@ jobs:
echo "Releasing version: $VERSION"

- name: Check if already released
id: check
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
echo "skip=true" >> $GITHUB_OUTPUT
fi

- name: Configure git
if: steps.check.outputs.skip != 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Create release branch
if: steps.check.outputs.skip != 'true'
run: git checkout -b "jfrog-workers-${{ steps.version.outputs.version }}"

- name: Setup Node.js
if: steps.check.outputs.skip != 'true'
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org/'

- name: Create npmrc
if: steps.check.outputs.skip != 'true'
working-directory: ./api
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand All @@ -67,38 +72,45 @@ jobs:
EOF

- name: Install dependencies
if: steps.check.outputs.skip != 'true'
working-directory: ./api
run: npm install --no-progress

- name: Commit version bump
if: steps.check.outputs.skip != 'true'
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
if: steps.check.outputs.skip != 'true'
working-directory: ./api
run: npm run build

- name: Publish to npm
if: steps.check.outputs.skip != 'true'
working-directory: ./api
run: |
echo "Publishing API npm package"
npm publish
echo "Publishing API npm package done"

- name: Push release branch
if: steps.check.outputs.skip != 'true'
run: git push origin "jfrog-workers-${{ steps.version.outputs.version }}"

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

- name: Merge to main
if: steps.check.outputs.skip != 'true'
run: |
BRANCH="jfrog-workers-${{ steps.version.outputs.version }}"
git fetch origin main
Expand Down