Skip to content

Commit d82e04c

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

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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"
26+
git config user.email "actions@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+
MAJOR="${PARTS[0]}"
40+
MINOR="${PARTS[1]}"
41+
PATCH="${PARTS[2]}"
42+
43+
# Add 100 to major version
44+
NEW_MAJOR=$((MAJOR + 100))
45+
46+
# Get build metadata
47+
DATE=$(date +'%Y%m%d')
48+
SHORT_HASH=$(git rev-parse --short HEAD)
49+
50+
SHADOW_VERSION="$NEW_MAJOR.$MINOR.$PATCH-xelp-$DATE-$SHORT_HASH"
51+
52+
echo "Shadow version: $SHADOW_VERSION"
53+
echo "shadow_version=$SHADOW_VERSION" >> $GITHUB_OUTPUT
54+
55+
- name: Install dependencies
56+
run: npm ci
57+
58+
- name: Update package.json version
59+
run: |
60+
npm version ${{ steps.version.outputs.shadow_version }} --no-git-tag-version --ignore-scripts
61+
62+
- name: Build
63+
run: npm run build
64+
65+
- name: Commit and Push
66+
run: |
67+
set -e
68+
git checkout -b xelp/dist
69+
git add -f dist/ package.json package-lock.json
70+
git commit -m "Release shadow version ${{ steps.version.outputs.shadow_version }}"
71+
git tag "v${{ steps.version.outputs.shadow_version }}"
72+
git push origin xelp/dist --force
73+
git push origin "v${{ steps.version.outputs.shadow_version }}"

0 commit comments

Comments
 (0)