Skip to content
Merged
Show file tree
Hide file tree
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
101 changes: 0 additions & 101 deletions .github/workflows/draft-release-from-pr.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/pr-auto-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: PR Auto Label

on:
pull_request:
types: [opened, edited, reopened, synchronize]

permissions:
pull-requests: write
contents: read

jobs:
label:
runs-on: ubuntu-latest
steps:
- name: Label PR by title
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TITLE: ${{ github.event.pull_request.title }}
PR: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
label=""

if [[ "$TITLE" =~ \(major\) ]]; then
label="major"
elif [[ "$TITLE" =~ \(minor\) ]]; then
label="minor"
elif [[ "$TITLE" =~ \(patch\) ]]; then
label="patch"
fi

if [[ -n "$label" ]]; then
echo "Found label: $label"
gh pr edit "$PR" --repo "$REPO" --add-label "$label"
else
echo "No label found in title: $TITLE"
fi
96 changes: 96 additions & 0 deletions .github/workflows/publish-release-on-pr-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Publish Release on PR Merge

on:
pull_request:
types: [closed]
branches: [main]

permissions:
contents: write
pull-requests: read

jobs:
publish-release:
runs-on: ubuntu-latest
if: >-
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'fireblocks-cli/generated/')
steps:
- name: Check for existing release
id: existing
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
marker="<!-- fireblocks-cli-generator:source-pr=${PR_NUMBER} -->"
existing_url=$(gh release list --limit 20 --json tagName,url \
--jq '.[].tagName' | while read -r tag; do
body=$(gh release view "$tag" --json body --jq '.body')
if [[ "$body" == *"$marker"* ]]; then
gh release view "$tag" --json url --jq '.url'
break
fi
done)

if [[ -n "$existing_url" ]]; then
echo "Release for PR #${PR_NUMBER} was already published (found idempotency marker) - skipping."
echo "Existing release: $existing_url"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi

- name: Calculate next version
id: version
if: steps.existing.outputs.skip == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
LAST_TAG=$(gh release list --limit 1 --json tagName -q '.[0].tagName')
if [[ -z "$LAST_TAG" || "$LAST_TAG" == "null" ]]; then
echo "ERROR: No existing release found. A release tag is required to calculate the next version."
exit 1
fi
echo "Found latest release: $LAST_TAG"

V="${LAST_TAG#v}"
MAJOR=$(echo "$V" | cut -d. -f1)
MINOR=$(echo "$V" | cut -d. -f2)
PATCH=$(echo "$V" | cut -d. -f3)

if [[ "$PR_TITLE" =~ \(major\) ]]; then
echo "Bumping MAJOR version"
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
elif [[ "$PR_TITLE" =~ \(minor\) ]]; then
echo "Bumping MINOR version"
MINOR=$((MINOR + 1))
PATCH=0
else
echo "Bumping PATCH version"
PATCH=$((PATCH + 1))
fi

echo "version=v${MAJOR}.${MINOR}.${PATCH}" >> "$GITHUB_OUTPUT"

- name: Create published release
if: steps.existing.outputs.skip == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_BODY: ${{ github.event.pull_request.body }}
MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
VERSION: ${{ steps.version.outputs.version }}
run: |
marker="<!-- fireblocks-cli-generator:source-pr=${PR_NUMBER} -->"
notes=$(printf '%s\n\n%s' "$PR_BODY" "$marker")

echo "Creating published release: $VERSION (target: $MERGE_SHA)"
gh release create "$VERSION" \
--target "$MERGE_SHA" \
--title "$VERSION" \
--notes "$notes"

echo "Published release created successfully!"
53 changes: 41 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ name: Publish
on:
release:
types: [released]
workflow_dispatch:
inputs:
version:
description: 'Version to use for this test run (no commit/push/tag/publish will actually happen)'
required: false
default: '0.0.0-test'

jobs:
build-and-test:
Expand Down Expand Up @@ -53,27 +59,39 @@ jobs:
npm i -g auto-changelog

- name: Bump version and add changelog
env:
INITIAL_TAG: ${{ github.event.release.tag_name || inputs.version }}
# TEMPORARY DRY-RUN OVERRIDE - forces test mode even for real releases.
# Original: ${{ github.event_name == 'workflow_dispatch' }}
# Revert this commit before running a real release.
IS_TEST_RUN: 'true'
run: |
initialTag=${{ github.event.release.tag_name }}
tag="${initialTag//[v]/}"
echo $tag
tag="${INITIAL_TAG//[v]/}"
echo "$tag"
git remote update
git fetch
git checkout --track origin/main
git config --global user.email "github-actions@github.com"
git config --global user.name "Github Actions"
npm --no-git-tag-version --allow-same-version version $tag
npm --no-git-tag-version --allow-same-version version "$tag"
auto-changelog
git add .
git commit -m "dump new version $tag"
git push
if [ "$IS_TEST_RUN" = "true" ]; then
echo "Test run: skipping git push"
else
git push
fi

- name: Move tag
# TEMPORARY DRY-RUN OVERRIDE - original: github.event_name == 'release'
if: false
env:
TAG_NAME: ${{ github.event.release.tag_name }}
run: |
TAG_NAME=${{ github.event.release.tag_name }}
echo $TAG_NAME
git tag --force $TAG_NAME
git push --force origin $TAG_NAME
echo "$TAG_NAME"
git tag --force "$TAG_NAME"
git push --force origin "$TAG_NAME"

pack-tarballs:
needs: bump-version
Expand Down Expand Up @@ -286,12 +304,23 @@ jobs:
run: yarn build

- name: Publish package
run: npx --yes npm@^11 publish --access public
env:
# TEMPORARY DRY-RUN OVERRIDE - original: ${{ github.event_name == 'workflow_dispatch' }}
IS_TEST_RUN: 'true'
run: |
if [ "$IS_TEST_RUN" = "true" ]; then
npx --yes npm@^11 publish --access public --dry-run
else
npx --yes npm@^11 publish --access public
fi
# No NODE_AUTH_TOKEN needed - OIDC handles authentication


upload-release-assets:
needs: [pack-tarballs, pack-macos, pack-deb, pack-windows]
# TEMPORARY DRY-RUN OVERRIDE - original: github.event_name == 'release'
# Skipping this also skips update-homebrew, which depends on it.
if: false
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down Expand Up @@ -324,8 +353,8 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
TAG: ${{ github.event.release.tag_name }}
run: |
TAG=${{ github.event.release.tag_name }}
echo "Uploading assets to release $TAG..."
for file in dist/tarballs/* dist/macos/* dist/linux-deb/* dist/windows/*; do
[ -f "$file" ] || continue
Expand All @@ -349,8 +378,8 @@ jobs:
- name: Update Homebrew formula
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
TAG: ${{ github.event.release.tag_name }}
run: |
TAG=${{ github.event.release.tag_name }}
VERSION="${TAG#v}"

BASE_URL="https://github.com/fireblocks/fireblocks-cli/releases/download/${TAG}"
Expand Down
Loading
Loading