update xverse signPsbt to use new request method from sats-connect #640
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- dev | |
- main | |
permissions: | |
contents: write | |
jobs: | |
# Check for package changes | |
check-package-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
lasereyes_changed: ${{ steps.check.outputs.lasereyes_changed }} | |
lasereyes_core_changed: ${{ steps.check.outputs.lasereyes_core_changed }} | |
lasereyes_react_changed: ${{ steps.check.outputs.lasereyes_react_changed }} | |
lasereyes_vue_changed: ${{ steps.check.outputs.lasereyes_vue_changed }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Fetch all branches | |
run: git fetch --all | |
- name: Determine diff comparison strategy | |
id: diff-strategy | |
run: | | |
if [ "${{ github.ref }}" == "refs/heads/dev" ]; then | |
echo "diff_target=HEAD^1" >> $GITHUB_ENV | |
elif [ "${{ github.ref }}" == "refs/heads/main" ]; then | |
echo "diff_target=HEAD^1" >> $GITHUB_ENV | |
fi | |
- name: Check if packages changed | |
id: check | |
run: | | |
diff_target=${{ env.diff_target }} | |
if git diff --name-only --diff-filter=AM $diff_target HEAD -- packages/lasereyes/ | grep -q '^packages/lasereyes/'; then | |
echo "lasereyes_changed=true" >> $GITHUB_ENV | |
echo "lasereyes_changed=true" >> $GITHUB_OUTPUT | |
else | |
echo "lasereyes_changed=false" >> $GITHUB_ENV | |
echo "lasereyes_changed=false" >> $GITHUB_OUTPUT | |
fi | |
if git diff --name-only --diff-filter=AM $diff_target HEAD -- packages/lasereyes-core/ | grep -q '^packages/lasereyes-core/'; then | |
echo "lasereyes_core_changed=true" >> $GITHUB_ENV | |
echo "lasereyes_core_changed=true" >> $GITHUB_OUTPUT | |
else | |
echo "lasereyes_core_changed=false" >> $GITHUB_ENV | |
echo "lasereyes_core_changed=false" >> $GITHUB_OUTPUT | |
fi | |
if git diff --name-only --diff-filter=AM $diff_target HEAD -- packages/lasereyes-react/ | grep -q '^packages/lasereyes-react/'; then | |
echo "lasereyes_react_changed=true" >> $GITHUB_ENV | |
echo "lasereyes_react_changed=true" >> $GITHUB_OUTPUT | |
else | |
echo "lasereyes_react_changed=false" >> $GITHUB_ENV | |
echo "lasereyes_react_changed=false" >> $GITHUB_OUTPUT | |
fi | |
if git diff --name-only --diff-filter=AM $diff_target HEAD -- packages/lasereyes-vue/ | grep -q '^packages/lasereyes-vue/'; then | |
echo "lasereyes_vue_changed=true" >> $GITHUB_ENV | |
echo "lasereyes_vue_changed=true" >> $GITHUB_OUTPUT | |
else | |
echo "lasereyes_vue_changed=false" >> $GITHUB_ENV | |
echo "lasereyes_vue_changed=false" >> $GITHUB_OUTPUT | |
fi | |
# Bump RC version in dev branch only if necessary, and skip if it's on the main branch | |
bump-rc-in-dev: | |
runs-on: ubuntu-latest | |
needs: check-package-changes | |
if: github.ref == 'refs/heads/dev' && | |
(needs.check-package-changes.outputs.lasereyes_changed == 'true' || | |
needs.check-package-changes.outputs.lasereyes_core_changed == 'true' || | |
needs.check-package-changes.outputs.lasereyes_react_changed == 'true' || | |
needs.check-package-changes.outputs.lasereyes_vue_changed == 'true') | |
environment: prod | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Setup pnpm | |
run: | | |
corepack enable | |
corepack prepare [email protected] --activate | |
- name: Install dependencies | |
run: pnpm install | |
- name: Create .npmrc file | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Bump versions sequentially if packages changed | |
run: | | |
# Bump lasereyes if any package has changed | |
if [[ "${{ needs.check-package-changes.outputs.lasereyes_changed }}" == "true" || \ | |
"${{ needs.check-package-changes.outputs.lasereyes_core_changed }}" == "true" || \ | |
"${{ needs.check-package-changes.outputs.lasereyes_react_changed }}" == "true" ]]; then | |
cd packages/lasereyes | |
pnpm version prerelease --preid=rc | |
cd ../.. | |
fi | |
# Bump lasereyes-core if changed | |
if [[ "${{ needs.check-package-changes.outputs.lasereyes_core_changed }}" == "true" ]]; then | |
cd packages/lasereyes-core | |
pnpm version prerelease --preid=rc | |
cd ../.. | |
fi | |
# Bump lasereyes-react if changed | |
if [[ "${{ needs.check-package-changes.outputs.lasereyes_react_changed }}" == "true" ]]; then | |
cd packages/lasereyes-react | |
pnpm version prerelease --preid=rc | |
cd ../.. | |
fi | |
# Bump lasereyes-vue if changed | |
if [[ "${{ needs.check-package-changes.outputs.lasereyes_vue_changed }}" == "true" ]]; then | |
cd packages/lasereyes-vue | |
pnpm version prerelease --preid=rc | |
cd ../.. | |
fi | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Configure git user | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Commit RC version bumps for all packages | |
run: | | |
git add . | |
git commit -m "RC version bump for all changed packages" | |
git push origin dev | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
promote-to-stable-in-main: | |
runs-on: ubuntu-latest | |
needs: check-package-changes | |
if: github.ref == 'refs/heads/main' | |
environment: prod | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: main | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Setup pnpm | |
run: | | |
corepack enable | |
corepack prepare [email protected] --activate | |
- name: Install dependencies | |
id: install_dependencies | |
run: pnpm install --no-frozen-lockfile | |
continue-on-error: true | |
- name: Build all packages | |
id: build_packages | |
run: pnpm build --filter="@omnisat*" | |
continue-on-error: true | |
# Set a flag if either critical step fails | |
- name: Check for failure in critical steps | |
if: steps.install_dependencies.outcome == 'failure' || steps.build_packages.outcome == 'failure' | |
run: echo "critical_failure=true" >> $GITHUB_ENV | |
- name: Create .npmrc file | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# Skip the remaining steps if critical steps failed | |
- name: Promote lasereyes-core version | |
if: env.critical_failure != 'true' && needs.check-package-changes.outputs.lasereyes_core_changed == 'true' | |
run: | | |
cd packages/lasereyes-core | |
pnpm version patch | |
pnpm publish --access public --no-git-checks | |
cd ../.. | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Promote lasereyes-react version | |
if: env.critical_failure != 'true' && needs.check-package-changes.outputs.lasereyes_react_changed == 'true' | |
run: | | |
cd packages/lasereyes-react | |
pnpm version patch | |
pnpm publish --access public --no-git-checks | |
cd ../.. | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Promote lasereyes-vue version | |
if: env.critical_failure != 'true' && needs.check-package-changes.outputs.lasereyes_vue_changed == 'true' | |
run: | | |
cd packages/lasereyes-vue | |
pnpm version patch | |
pnpm publish --access public --no-git-checks | |
cd ../.. | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# Update dependencies in lasereyes package.json only if no critical failure | |
- name: Update dependencies in lasereyes package.json | |
if: env.critical_failure != 'true' && (needs.check-package-changes.outputs.lasereyes_core_changed == 'true' || needs.check-package-changes.outputs.lasereyes_react_changed == 'true') | |
run: | | |
CORE_VERSION=$(cd packages/lasereyes-core && node -p "require('./package.json').version") | |
REACT_VERSION=$(cd packages/lasereyes-react && node -p "require('./package.json').version") | |
echo "New lasereyes-core version: $CORE_VERSION" | |
echo "New lasereyes-react version: $REACT_VERSION" | |
cd packages/lasereyes | |
node -e "let pkg=require('./package.json'); pkg.dependencies['@omnisat/lasereyes-core']='$CORE_VERSION'; pkg.dependencies['@omnisat/lasereyes-react']='$REACT_VERSION'; require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2));" | |
cd ../.. | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Promote lasereyes version | |
if: env.critical_failure != 'true' && (needs.check-package-changes.outputs.lasereyes_changed == 'true' || needs.check-package-changes.outputs.lasereyes_core_changed == 'true' || needs.check-package-changes.outputs.lasereyes_react_changed == 'true') | |
run: | | |
cd packages/lasereyes | |
pnpm version patch | |
pnpm publish --access public --no-git-checks | |
cd ../.. | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Revert dependencies in lasereyes package.json for local development | |
if: needs.check-package-changes.outputs.lasereyes_core_changed == 'true' || needs.check-package-changes.outputs.lasereyes_react_changed == 'true' | |
continue-on-error: true | |
run: | | |
cd packages/lasereyes | |
node -e "let pkg=require('./package.json'); pkg.dependencies['@omnisat/lasereyes-core']='workspace:*'; pkg.dependencies['@omnisat/lasereyes-react']='workspace:*'; require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2));" | |
cd ../.. | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Commit stable version bump for all changed packages | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Action" | |
git fetch --prune # Clean up stale references | |
git add . | |
git commit -m "Stable version bump for all changed packages" | |
git checkout main || git checkout -b main origin/main # Ensure main branch is checked out | |
git branch --set-upstream-to=origin/main main # Set upstream to avoid ambiguity | |
git push origin main:refs/heads/main # Push explicitly to main branch | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Revert merge if critical steps failed | |
if: env.critical_failure == 'true' | |
run: | | |
PREV_MAIN_COMMIT=$(git rev-parse main^1) | |
git reset --hard $PREV_MAIN_COMMIT | |
git push origin main --force | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Reopen PR from dev to main if critical steps failed | |
if: env.critical_failure == 'true' | |
run: | | |
PR_NUMBER=$(gh pr list --state closed --base main --head dev --limit 1 --json number --jq '.[0].number') | |
if [ -n "$PR_NUMBER" ]; then | |
gh pr reopen $PR_NUMBER | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Merge main into dev to sync branches | |
merge-main-into-dev: | |
runs-on: ubuntu-latest | |
needs: | |
- promote-to-stable-in-main | |
- generate-release-notes-main | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Setup pnpm | |
run: | | |
corepack enable | |
corepack prepare [email protected] --activate | |
- name: Install dependencies | |
run: pnpm install --no-frozen-lockfile | |
- name: Configure git user | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Checkout dev branch | |
run: | | |
git checkout dev | |
git fetch origin | |
git merge -s recursive -X theirs origin/main || echo "Handled merge conflicts with 'theirs' strategy" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push merge to dev | |
run: | | |
git push origin dev | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
bump-next-rc-in-dev: | |
runs-on: ubuntu-latest | |
needs: | |
- merge-main-into-dev | |
- check-package-changes | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: dev | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Setup pnpm | |
run: | | |
corepack enable | |
corepack prepare [email protected] --activate | |
- name: Install dependencies | |
run: pnpm install --no-frozen-lockfile | |
# Debugging Step: Log the outputs to check if they're correctly set | |
- name: Log outputs from check-package-changes | |
run: | | |
echo "Lasereyes changed: ${{ needs.check-package-changes.outputs.lasereyes_changed }}" | |
echo "Lasereyes-core changed: ${{ needs.check-package-changes.outputs.lasereyes_core_changed }}" | |
echo "Lasereyes-react changed: ${{ needs.check-package-changes.outputs.lasereyes_react_changed }}" | |
echo "Lasereyes-react changed: ${{ needs.check-package-changes.outputs.lasereyes_vue_changed }}" | |
- name: Bump lasereyes version if any package changed | |
if: needs.check-package-changes.outputs.lasereyes_changed == 'true' || | |
needs.check-package-changes.outputs.lasereyes_core_changed == 'true' || | |
needs.check-package-changes.outputs.lasereyes_react_changed == 'true' | |
run: | | |
cd packages/lasereyes | |
pnpm version prerelease --preid=rc | |
- name: Bump lasereyes-core version if changed | |
if: needs.check-package-changes.outputs.lasereyes_core_changed == 'true' | |
run: | | |
cd packages/lasereyes-core | |
pnpm version prerelease --preid=rc | |
- name: Bump lasereyes-react version if changed | |
if: needs.check-package-changes.outputs.lasereyes_react_changed == 'true' | |
run: | | |
cd packages/lasereyes-react | |
pnpm version prerelease --preid=rc | |
- name: Bump lasereyes-vue version if changed | |
if: needs.check-package-changes.outputs.lasereyes_vue_changed == 'true' | |
run: | | |
cd packages/lasereyes-vue | |
pnpm version prerelease --preid=rc | |
- name: Configure git user | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Commit RC version bumps for all packages | |
if: needs.check-package-changes.outputs.lasereyes_changed == 'true' || | |
needs.check-package-changes.outputs.lasereyes_core_changed == 'true' || | |
needs.check-package-changes.outputs.lasereyes_react_changed == 'true' || | |
needs.check-package-changes.outputs.lasereyes_vue_changed == 'true' | |
run: | | |
git add . | |
git commit -m "Next RC version bump for all changed packages" | |
git push origin dev | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
generate-release-notes-dev: | |
runs-on: ubuntu-latest | |
needs: bump-rc-in-dev | |
if: github.ref == 'refs/heads/dev' | |
continue-on-error: true | |
environment: prod | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install openai==0.28 requests | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
- name: Generate git diff | |
run: | | |
PREV_COMMIT=$(git rev-parse HEAD^1) | |
git diff $PREV_COMMIT HEAD > changes.diff | |
- name: Extract new version | |
id: extract-version | |
run: | | |
NEW_VERSION=$(node -p "require('./packages/lasereyes/package.json').version") | |
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
- name: Generate release notes with GPT | |
run: | | |
set -e | |
python3 scripts/generate_release_notes.py ${{ env.NEW_VERSION }} | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
# Generate and commit release notes for the main branch | |
generate-release-notes-main: | |
runs-on: ubuntu-latest | |
needs: promote-to-stable-in-main | |
if: github.ref == 'refs/heads/main' | |
continue-on-error: true | |
environment: prod | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install openai==0.28 requests | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
- name: Generate git diff | |
run: | | |
PREV_COMMIT=$(git rev-parse HEAD^1) | |
git diff $PREV_COMMIT HEAD > changes.diff | |
- name: Extract new version | |
id: extract-version | |
run: | | |
NEW_VERSION=$(node -p "require('./packages/lasereyes/package.json').version") | |
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
- name: Generate release notes with GPT | |
run: | | |
set -e | |
python3 scripts/generate_release_notes.py ${{ env.NEW_VERSION }} | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
- name: Configure git user | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Commit and push release notes | |
run: | | |
echo -e "\n$(cat detailed_release_notes.md)\n$(cat RELEASE_NOTES.md)" > RELEASE_NOTES.md | |
git add RELEASE_NOTES.md | |
git commit -m "Updated RELEASE_NOTES.md with new release" | |
git pull origin main --rebase | |
git push origin main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create GitHub Release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: '${{ env.NEW_VERSION }}' | |
release_name: 'Release ${{ env.NEW_VERSION }}' | |
body_path: RELEASE_NOTES.md | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |