Skip to content

Commit

Permalink
ci: few last changes to the release creation pipeline (#42)
Browse files Browse the repository at this point in the history
* few last changes to the release creation pipeline

* [bot] New pkg version: 0.0.0-alpha.5

* Fix npm publish to release from release tag instead of head of main
  • Loading branch information
gpmayorga authored Jan 9, 2025
1 parent d87edb1 commit 1e4b291
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 29 deletions.
49 changes: 22 additions & 27 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name: Release and Versioning
on:
push:
branches:
- main
pull_request:
types: [opened, reopened, labeled, synchronize]
types: [opened, reopened, labeled, synchronize, closed]

jobs:
version-bump:
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' && github.event.action != 'closed'
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -17,31 +14,21 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref || github.ref_name }}
ref: ${{ github.event.pull_request.head.ref || github.ref_name }}

- name: Check PR labels
id: check_labels
env:
GH_TOKEN: ${{ github.token }}
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
echo "::notice::PR used to check version bump: #$PR_NUMBER"
LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name')
# Make script executable
chmod +x ./.github/ci-scripts/pr-label-check.sh
# Run the script and capture both output and exit code
RELEASE_TYPE=$(./.github/ci-scripts/pr-label-check.sh $PR_NUMBER 2>&1) || {
# If script exits with non-zero, output the error and exit
echo "::error::Script failed with output: $RELEASE_TYPE"
exit 1
}
RELEASE_TYPE=$(./.github/ci-scripts/pr-label-check.sh $PR_NUMBER)
echo "version=$RELEASE_TYPE" >> $GITHUB_OUTPUT
echo "::notice::Release label detected: $RELEASE_TYPE"
echo "::notice::$RELEASE_TYPE label detected on PR #$PR_NUMBER"
if [ "$RELEASE_TYPE" == "no-release" ]; then
echo "::notice::PR is not flagged for release, skipping bump"
echo "::notice::PR is not flagged for release, skipping version bump"
fi
- name: Bump version
Expand Down Expand Up @@ -92,19 +79,27 @@ jobs:
create-release:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.event.pull_request.merged == true && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Create GitHub Release
# if: steps.check_labels.outputs.version != 'no-release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=$(node -p "require('./package.json').version")
gh release create "v${VERSION}" \
--title "Release v${VERSION}" \
--generate-notes \
--prerelease \
--target "${GITHUB_SHA}"
PR_NUMBER=$(gh pr list --state merged --json number --jq '.[0].number')
chmod +x ./.github/ci-scripts/pr-label-check.sh
RELEASE_TYPE=$(./.github/ci-scripts/pr-label-check.sh $PR_NUMBER)
echo "::notice::Last PR merged detected: #$PR_NUMBER) with release label: $RELEASE_TYPE"
if [ "$RELEASE_TYPE" != "no-release" ]; then
VERSION=$(node -p "require('./package.json').version")
gh release create "v${VERSION}" \
--title "Release v${VERSION}" \
--generate-notes \
--prerelease \
--target "${GITHUB_SHA}"
fi
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: main
ref: ${{ github.ref }}

- uses: actions/setup-node@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@centrifuge/sdk",
"version": "0.0.0-alpha.4",
"version": "0.0.0-alpha.5",
"description": "",
"homepage": "https://github.com/centrifuge/sdk/tree/main#readme",
"author": "",
Expand Down

0 comments on commit 1e4b291

Please sign in to comment.