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
92 changes: 0 additions & 92 deletions .github/workflows/draft-release-from-pr.yml

This file was deleted.

47 changes: 37 additions & 10 deletions .github/workflows/publish-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ name: Publish Maven
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version to use for this test run (no commit/push/tag/deploy will actually happen)'
required: false
default: '0.0.0-test'

jobs:
bump-version:
Expand All @@ -29,10 +35,15 @@ jobs:
pip install bump-my-version
npm i -g auto-changelog
- name: Bump version
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
echo "finished fetching"
Expand All @@ -41,18 +52,25 @@ jobs:
git config --global user.email "github-actions@github.com"
git config --global user.name "Github Actions"
echo "finished configuration"
bump-my-version bump --config-file .bump_version.toml --current-version 0.0.0 --new-version $tag
bump-my-version bump --config-file .bump_version.toml --current-version 0.0.0 --new-version "$tag"
echo "bumpversion finished"
auto-changelog
git add .
git commit -m "release $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
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"

publish:
needs: bump-version
Expand All @@ -78,7 +96,16 @@ jobs:
run: |
echo -n "${{ secrets.GPG_SIGNING_KEY }}" | base64 --decode | gpg --import --batch
- name: Publish package
run: mvn --batch-mode deploy -Dgpg.passphrase='${{ secrets.GPG_PASSWORD }}'
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_OSSRH_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSWORD }}
# TEMPORARY DRY-RUN OVERRIDE - original: ${{ github.event_name == 'workflow_dispatch' }}
IS_TEST_RUN: 'true'
run: |
if [ "$IS_TEST_RUN" = "true" ]; then
# 'verify' runs through compile/test/package/sign without the 'deploy' phase, so nothing is uploaded
mvn --batch-mode verify -Dgpg.passphrase="$GPG_PASSPHRASE"
else
mvn --batch-mode deploy -Dgpg.passphrase="$GPG_PASSPHRASE"
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: [master]

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-api-spec/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-sdk-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-sdk-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!"
Loading
Loading