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

Update "Releases" page when a new tag is pushed to repo #281

Merged
merged 37 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4d26126
First pass on attempt
anmolshres98 Jan 14, 2025
425ce33
change name
anmolshres98 Jan 14, 2025
76b155b
try with on push
anmolshres98 Jan 14, 2025
681dad1
rename name
anmolshres98 Jan 14, 2025
3751802
change to `on: workflow_dispatch`
anmolshres98 Jan 14, 2025
c6f6d82
on tags push
anmolshres98 Jan 14, 2025
3901a24
also add on workflow_dispatch
anmolshres98 Jan 14, 2025
86c6bf0
try tag ref checkout
Jan 15, 2025
b7dd808
test release
Jan 15, 2025
d4a693c
try creating hard-coded release asset
Jan 15, 2025
2c6f02b
attempt with script file
Jan 15, 2025
d4977d2
attempt with hard coding
Jan 15, 2025
31f9a51
add relative path
Jan 15, 2025
e51ed23
attempt with absolute path
Jan 15, 2025
7cf91ad
correct absolute path
Jan 15, 2025
47cdffa
supply refName
Jan 15, 2025
6443f49
try fixing pathing
Jan 15, 2025
ae95625
testing assets
Jan 15, 2025
c2b6595
figured out zipping
Jan 15, 2025
a27330b
updated
Jan 15, 2025
3b86b1f
hard-code
Jan 15, 2025
2c53356
try try
Jan 15, 2025
7e5ea0e
fixer
Jan 15, 2025
9b63d82
try `\n`
Jan 15, 2025
40d07dd
spacebar
Jan 15, 2025
b976ef6
try not escaping
Jan 15, 2025
84c017b
entire shell script
Jan 15, 2025
23cb9c6
try with "refs/tags/"
Jan 15, 2025
c4fac63
final shell script version
Jan 15, 2025
e9db6d3
test code
Jan 15, 2025
d73e674
delete the test package
Jan 15, 2025
fc878ed
narrow tag name match pattern
Jan 16, 2025
d59b112
fix git config user.email
anmolshres98 Jan 16, 2025
f54d487
zip distributables
anmolshres98 Jan 17, 2025
7604a76
hardcoding for testing
anmolshres98 Jan 17, 2025
41fe234
undo test code
anmolshres98 Jan 17, 2025
6bc8c44
update comment
anmolshres98 Jan 17, 2025
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
36 changes: 36 additions & 0 deletions .github/workflows/create-github-release.yaml
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 }}
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

Expand All @@ -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
aruniverse marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/scripts/create-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash
aruniverse marked this conversation as resolved.
Show resolved Hide resolved

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 directory with just the specific package
aruniverse marked this conversation as resolved.
Show resolved Hide resolved
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
Loading