-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update "Releases" page when a new tag is pushed to repo (#281)
Co-authored-by: anmolshres98 <[email protected]>
- Loading branch information
1 parent
b0e4594
commit ff67f5b
Showing
3 changed files
with
104 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Create GitHub Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '@itwin/*_v[0-9]+.[0-9]+.[0-9]+' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
create-release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout tag | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref }} # checkouts the branch that triggered the workflow | ||
fetch-depth: 0 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v4 | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Configure git | ||
run: | | ||
git config --local user.email [email protected] | ||
git config --local user.name imodeljs-admin | ||
- name: Create GitHub release | ||
run: | | ||
echo "Creating GitHub release for tag ${{ github.ref }}" | ||
bash .github/workflows/scripts/create-release.sh ${{ github.ref }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.IMJS_ADMIN_GH_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
# Workflow that will create a GitHub release a when a new release tag is pushed | ||
|
||
name: Create Release | ||
name: Publish Packages to npm | ||
|
||
on: workflow_dispatch | ||
|
||
|
@@ -18,19 +16,13 @@ jobs: | |
- name: Install pnpm | ||
uses: pnpm/action-setup@v4 | ||
|
||
- name: Use Node.js 18 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
registry-url: https://registry.npmjs.org/ | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Build, Lint, Test | ||
run: pnpm lage build lint cover | ||
|
||
- name: Publish packages | ||
- name: Publish packages and create git tags | ||
run: | | ||
git config --local user.email [email protected] | ||
git config --local user.name imodeljs-admin | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$1" ]; then | ||
echo "No refName was supplied" | ||
exit 1 | ||
fi | ||
|
||
refName=$1 | ||
echo "Ref name passed in: $refName" | ||
|
||
tagName=$(echo $refName | sed 's/refs\/tags\///') | ||
echo "Tag name was parsed as: $tagName" | ||
packageName=$(echo $tagName | sed 's/_v.*//') | ||
echo "Package name was parsed as: $packageName" | ||
packageVersion=$(echo $tagName | sed 's/.*_v//') | ||
echo "Package version was parsed as: $packageVersion" | ||
|
||
# The packageDirectory variable is determined by searching the ./packages directory for a subdirectory | ||
# that contains a package.json file with a name matching the parsed packageName. | ||
# determine package directory so that we can zip it up and also find the changelog | ||
packageDirectory=$(find ./packages -maxdepth 1 -type d | while read dir; do | ||
if [ -f "$dir/package.json" ]; then | ||
packageNameInJson=$(jq -r '.name' "$dir/package.json") | ||
if [ "$packageNameInJson" == "$packageName" ]; then | ||
echo "$dir" | ||
break | ||
fi | ||
fi | ||
done) | ||
if [ -z "$packageDirectory" ]; then | ||
echo "No package directory found for package name: $packageName" | ||
exit 1 | ||
else | ||
echo "Package directory was determined as: $packageDirectory" | ||
fi | ||
cd $packageDirectory | ||
changelogMd="CHANGELOG.md" | ||
if [ ! -f "$changelogMd" ]; then | ||
echo "Changelog file not found: $changelogMd" | ||
exit 1 | ||
fi | ||
# build the package and create consumable to release | ||
pnpm build | ||
# Extract the changelog text | ||
releaseNoteText=$(awk -v version="$packageVersion" '$0 ~ version {flag=1; print; next} /^## /{flag=0} flag' "$changelogMd") | ||
echo "Release note text was extracted as: $releaseNoteText" | ||
# remove the @itwin/ or @bentley/ scope from the tag name to create the zip file name since they have special characters | ||
zipFileName=$(echo "$tagName" | sed 's/@itwin\///; s/@bentley\///') | ||
echo "Zip file name was parsed as: $zipFileName" | ||
# Zip the package deliverables - lib and dist directories | ||
zip -r "$zipFileName.zip" lib dist | ||
tar -czvf "$zipFileName.tar.gz" lib dist | ||
# Create a release and upload assets | ||
gh release create "$tagName" \ | ||
"$zipFileName.zip" \ | ||
"$zipFileName.tar.gz" \ | ||
--notes "$releaseNoteText" \ | ||
--verify-tag |