Skip to content

Commit

Permalink
Updated pre-push and release
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebGerman committed Jan 9, 2025
1 parent d864d7c commit 19cf124
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
12 changes: 5 additions & 7 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ if [[ "$BRANCH_NAME" =~ ^release/changed-elements-react-v[0-9a-zA-Z]+\.[0-9a-zA-
# Extract version from package.json
PACKAGE_VERSION=$(grep -oP '"version": "\K[0-9]+\.[0-9]+\.[0-9]+' packages/changed-elements-react/package.json)

echo "Package version: $PACKAGE_VERSION"
echo "CHANGELOG version: $VERSION"

# Compare versions
if [ "$VERSION" != "$PACKAGE_VERSION" ]; then
echo "Package version: $PACKAGE_VERSION"
echo "CHANGELOG version: $VERSION"
echo "Version mismatch: CHANGELOG.md version ($VERSION) does not match package.json version ($PACKAGE_VERSION). Please run npx changeset version. Then run again. For more details read publish_readme.md"
exit 1
fi
Expand All @@ -27,12 +26,11 @@ if [[ "$BRANCH_NAME" =~ ^release/changed-elements-react-v[0-9a-zA-Z]+\.[0-9a-zA-
PACKAGE_MAJOR_MINOR=$(echo "$PACKAGE_VERSION" | grep -oP '^[0-9]+\.[0-9]+')
CHANGELOG_MAJOR_MINOR=$(echo "$VERSION" | grep -oP '^[0-9]+\.[0-9]+')

echo "Branch major.minor version: $BRANCH_VERSION"
echo "Package major.minor version: $PACKAGE_MAJOR_MINOR"
echo "CHANGELOG major.minor version: $CHANGELOG_MAJOR_MINOR"

# Compare branch major.minor version with package and changelog major.minor versions
if [ "$BRANCH_VERSION" != "$PACKAGE_MAJOR_MINOR" ] || [ "$BRANCH_VERSION" != "$CHANGELOG_MAJOR_MINOR" ]; then
echo "Branch major.minor version: $BRANCH_VERSION"
echo "Package major.minor version: $PACKAGE_MAJOR_MINOR"
echo "CHANGELOG major.minor version: $CHANGELOG_MAJOR_MINOR"
echo "Version mismatch: release branch major.minor version ($BRANCH_VERSION) does not equal CHANGELOG.md major.minor version ($CHANGELOG_MAJOR_MINOR) or package.json major.minor version ($PACKAGE_MAJOR_MINOR). Please run npx changeset version. Then run again. For more details read publish_readme.md"
exit 1
fi
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,30 @@ on:
- 'release/changed-elements-react-v*.*.*'

jobs:
tag:
CreateRelease:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Extract version and release notes from CHANGELOG.md
id: extract_version_and_notes
- name: Extract version from package.json
id: extract_version
run: |
VERSION=$(grep -oP '^## \K[0-9]+\.[0-9]+\.[0-9]+' packages/changed-elements-react/CHANGELOG.md | head -1)
NOTES=$(awk '/^## '"$VERSION"'/{flag=1;next}/^##/{flag=0}flag' packages/changed-elements-react/CHANGELOG.md)
VERSION=$(jq -r '.version' packages/changed-elements-react/package.json)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Extracted version: $VERSION"
- name: Extract release notes from CHANGELOG.md
id: extract_notes
run: |
NOTES=$(awk '/^## '"$VERSION"'/{flag=1;next}/^## [0-9]+\.[0-9]+\.[0-9]+/{flag=0}flag' packages/changed-elements-react/CHANGELOG.md)
echo "NOTES<<EOF" >> $GITHUB_ENV
echo "$NOTES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "Extracted notes: $NOTES"
shell: /usr/bin/bash -e {0}

- name: Create tag
run: |
Expand All @@ -37,7 +44,7 @@ jobs:
uses: actions/create-release@v1
with:
tag_name: "v${{ env.VERSION }}"
release_name: "Release ${{ env.VERSION }}"
release_name: "@itwin/changed-elements-react${{ env.VERSION }}"
body: ${{ env.NOTES }}
draft: false
prerelease: false
Expand Down

0 comments on commit 19cf124

Please sign in to comment.