Skip to content

Commit

Permalink
fix release
Browse files Browse the repository at this point in the history
  • Loading branch information
leordev committed Feb 15, 2024
1 parent 7e776b6 commit 0e7458b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
26 changes: 8 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ jobs:
release:
# prevents this action from running on forks
# if: github.repository == 'TBD54566975/tbdex-js'

# only executes this job if its a push to main or
# a labeled pull request from a branch named: changeset-release/main
if: (github.event_name == 'push' && github.ref =='refs/heads/main') || (github.event_name == 'pull_request' && github.event.label.name == 'api-release' && github.base_ref == 'changeset-release/main')

permissions:
contents: write # to create release (changesets/action)
pull-requests: write # to create pull request (changesets/action)
Expand All @@ -32,6 +37,8 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
ref: main

- name: Set up Node.js
uses: actions/setup-node@5ef044f9d09786428e6e895be6be17937becee3a #v4.0.0
Expand All @@ -45,23 +52,6 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm whoami

- name: Check @web5/api release
id: apirelease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
api_release_pr=$(gh pr list \
--base 'main' \
--head 'changeset-release/main' \
--json title,labels,number \
--jq '[.[] | select(.labels[]?.name == "api-release")] | first | .number')
if [[ -z "$api_release_pr" ]]; then
echo "This is a release without the Web5 API"
echo "::set-output name=ignore_release_args::--ignore @leordev-web5/api"
else
echo "Web5 API Release DETECTED"
fi
- name: Install dependencies
run: npm ci

Expand All @@ -73,7 +63,7 @@ jobs:
id: changesets
with:
publish: npx changeset publish
version: npx changeset version ${{ steps.apirelease.outputs.ignore_release_args }} && npm i --package-lock-only
version: scripts/changesets-version.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
23 changes: 23 additions & 0 deletions scripts/changesets-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

IGNORE_API_RELEASE=""

# check if there is a changeset PR with the api-release label
API_RELEASE_PR=$(gh pr list \
--base 'main' \
--head 'changeset-release/main' \
--json title,labels,number \
--jq '[.[] | select(.labels[]?.name == "api-release")] | first | .number')

# if there is no PR, then we release without the Web5 API
if [[ -z "$API_RELEASE_PR" ]]; then
echo "This is a release without the Web5 API"
IGNORE_API_RELEASE="--ignore @leordev-web5/api"
else
echo "Web5 API Release DETECTED"
fi

npx changeset version $IGNORE_API_RELEASE

# update package-lock.json
npm i --package-lock-only

0 comments on commit 0e7458b

Please sign in to comment.