Skip to content

Commit 150a2cc

Browse files
committed
[XELP] GHA shadow release
1 parent 31bdca0 commit 150a2cc

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Xelp Shadow Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
shadow-release:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
steps:
12+
- name: Checkout xelp/main
13+
uses: actions/checkout@v4
14+
with:
15+
ref: xelp/main
16+
fetch-depth: 0
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '18'
22+
23+
- name: Configure Git
24+
run: |
25+
git config user.name "github-actions[bot]"
26+
git config user.email "github-actions[bot]@users.noreply.github.com"
27+
28+
- name: Calculate XelpShadow Version
29+
id: version
30+
run: |
31+
CURRENT_VERSION=$(node -p "require('./package.json').version")
32+
echo "Current version: $CURRENT_VERSION"
33+
34+
# Remove pre-release and build metadata
35+
BASE_VERSION=$(echo "$CURRENT_VERSION" | sed 's/[-+].*//')
36+
37+
# Split version into parts
38+
IFS='.' read -r -a PARTS <<< "$BASE_VERSION"
39+
if [ ${#PARTS[@]} -ne 3 ]; then
40+
echo "Error: Version must be in MAJOR.MINOR.PATCH format"
41+
exit 1
42+
fi
43+
MAJOR="${PARTS[0]}"
44+
MINOR="${PARTS[1]}"
45+
PATCH="${PARTS[2]}"
46+
47+
# Get build metadata
48+
DATE=$(date +'%Y%m%d')
49+
SHORT_HASH=$(git rev-parse --short HEAD)
50+
51+
# Construct base version: MAJOR.MINOR.DATE<PATCH>
52+
BASE_VERSION_PREFIX="$MAJOR.$MINOR.$DATE$PATCH"
53+
54+
# Package version uses - for prerelease/metadata
55+
PACKAGE_VERSION="$BASE_VERSION_PREFIX-xelp-$SHORT_HASH"
56+
57+
# Tag version uses + for build metadata (so it looks stable)
58+
TAG_VERSION="$BASE_VERSION_PREFIX+xelp-$SHORT_HASH"
59+
60+
echo "Package version: $PACKAGE_VERSION"
61+
echo "Tag version: $TAG_VERSION"
62+
63+
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
64+
echo "tag_version=$TAG_VERSION" >> $GITHUB_OUTPUT
65+
66+
- name: Install dependencies
67+
run: npm ci
68+
69+
- name: Update package.json version
70+
run: |
71+
npm version ${{ steps.version.outputs.package_version }} --no-git-tag-version
72+
73+
- name: Build
74+
run: npm run build
75+
76+
- name: Commit and Push
77+
run: |
78+
set -e
79+
git checkout -b xelp/dist
80+
git add -f dist/ package.json package-lock.json
81+
git commit -m "Release shadow version ${{ steps.version.outputs.package_version }}"
82+
git tag "v${{ steps.version.outputs.tag_version }}"
83+
git push origin xelp/dist --force
84+
git push origin "v${{ steps.version.outputs.tag_version }}"

0 commit comments

Comments
 (0)