Skip to content

Commit 7133104

Browse files
authored
Shared configs/workflows/prerelease (#180)
* support pre-release tags * publish pre-releases to npm
1 parent 4955e09 commit 7133104

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

.github/workflows/release-package.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
id: find_tags
3333
shell: bash
3434
run: |
35-
TAGS=$(git tag --points-at HEAD | grep -E '^@instructure.ai/.+@([0-9]+\.[0-9]+\.[0-9]+)$' || true)
35+
TAGS=$(git tag --points-at HEAD | grep -E '^@instructure.ai/.+@([0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9\.-]+)?)$' || true)
3636
3737
# Output for conditionals in later steps
3838
echo "tags<<EOF" >> "$GITHUB_OUTPUT"
@@ -128,33 +128,48 @@ jobs:
128128
if [ -n "$JSON_PATH" ]; then
129129
ACCESS_PUBLIC=$(jq -r '.publishConfig.access // empty' "$JSON_PATH")
130130
PRIVATE=$(jq -r '.private // false' "$JSON_PATH")
131+
VERSION=$(jq -r '.version' "$JSON_PATH")
132+
# Extract prerelease id (e.g., alpha, beta, rc) if present
133+
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-([a-zA-Z0-9]+)\.[0-9]+$ ]]; then
134+
PRERELEASE_ID="${BASH_REMATCH[1]}"
135+
NPM_TAG="--tag $PRERELEASE_ID"
136+
else
137+
NPM_TAG=""
138+
fi
131139
if [ "$PRIVATE" = "true" ]; then
132140
echo "Skipping publish for $PKG_NAME because it is marked private."
133141
elif [ "$ACCESS_PUBLIC" = "public" ]; then
134142
echo "Publishing $PKG_NAME as public via npm (OIDC)…"
135-
npm publish "$TARBALL" --access public --provenance
143+
npm publish "$TARBALL" --access public --provenance $NPM_TAG
136144
elif [ -n "$ACCESS_PUBLIC" ] && [ "$ACCESS_PUBLIC" != "public" ]; then
137145
echo "Skipping publish for $PKG_NAME because publishConfig.access is '$ACCESS_PUBLIC'."
138146
else
139147
echo "Publishing $PKG_NAME via npm (no --access public)…"
140-
npm publish "$TARBALL" --provenance
148+
npm publish "$TARBALL" --provenance $NPM_TAG
141149
fi
142150
else
143151
echo "package.json not found for $PKG_NAME in packages, publishing without access check."
144-
npm publish "$TARBALL" --provenance
152+
npm publish "$TARBALL" --provenance $NPM_TAG
145153
fi
146154
else
147155
echo "Skipping publish for $PKG_NAME (not in /packages or is shared-configs)."
148156
fi
149157
150158
159+
# Determine if this is a prerelease (contains a hyphen after the patch version)
160+
if [[ "$TAG" =~ ^@instructure\.ai/.+@[0-9]+\.[0-9]+\.[0-9]+- ]]; then
161+
PRERELEASE_FLAG="--prerelease"
162+
else
163+
PRERELEASE_FLAG=""
164+
fi
165+
151166
# Create GitHub release (attach asset only for /packages)
152167
if [ "$PKG_NAME" = "shared-configs" ]; then
153-
gh release create "$TAG" --title "$TAG" --generate-notes
168+
gh release create "$TAG" --title "$TAG" --generate-notes $PRERELEASE_FLAG
154169
elif [ -d "packages/$PKG_NAME" ]; then
155-
gh release create "$TAG" ./packages/$PKG_NAME/src/*.tgz --title "$TAG" --generate-notes
170+
gh release create "$TAG" ./packages/$PKG_NAME/src/*.tgz --title "$TAG" --generate-notes $PRERELEASE_FLAG
156171
else
157-
gh release create "$TAG" --title "$TAG" --generate-notes
172+
gh release create "$TAG" --title "$TAG" --generate-notes $PRERELEASE_FLAG
158173
fi
159174
done
160175

0 commit comments

Comments
 (0)