Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: few last changes to the release creation pipeline #42

Merged
merged 7 commits into from
Jan 9, 2025
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
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
Loading