Skip to content

Commit 8bdf5de

Browse files
committed
feat: add GitHub Actions workflow for publishing alpha version of podverse-orm
1 parent 71c6dcd commit 8bdf5de

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Publish Alpha podverse-orm
2+
3+
on:
4+
push:
5+
branches:
6+
- v5-alpha
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: '20.16.0'
20+
registry-url: 'https://registry.npmjs.org'
21+
22+
- name: Install podverse-helpers latest alpha version
23+
run: |
24+
npm i podverse-helpers@alpha --save
25+
26+
- name: Clean install dependencies
27+
run: npm clean-install
28+
29+
- name: Increment alpha version
30+
id: version
31+
run: |
32+
PACKAGE_NAME=$(node -p "require('./package.json').name")
33+
BASE_VERSION=$(node -p "require('./package.json').version")
34+
# Strip any pre-release tag (e.g., '-develop') from BASE_VERSION
35+
BASE_VERSION=$(echo "$BASE_VERSION" | sed 's/-.*//')
36+
37+
# Try to get the current alpha version (e.g., 5.1.1-alpha.3)
38+
ALPHA_VERSION=$(npm dist-tag ls "$PACKAGE_NAME" 2>/dev/null | grep -w alpha | awk '{print $2}')
39+
40+
# If no alpha tag exists
41+
if [[ -z "$ALPHA_VERSION" ]]; then
42+
echo "No alpha version found. Starting with: $BASE_VERSION-alpha.0"
43+
NEXT_VERSION="$BASE_VERSION-alpha.0"
44+
else
45+
# Extract the base and numeric suffix from the current alpha version
46+
CURRENT_BASE=$(echo "$ALPHA_VERSION" | cut -d '-' -f 1)
47+
CURRENT_ALPHA_NUM=$(echo "$ALPHA_VERSION" | sed -En 's/.*alpha\.([0-9]+)$/\1/p')
48+
49+
# If current alpha is malformed or suffix missing
50+
if [[ -z "$CURRENT_ALPHA_NUM" ]]; then
51+
NEXT_VERSION="$BASE_VERSION-alpha.0"
52+
fi
53+
54+
if [[ "$CURRENT_BASE" == "$BASE_VERSION" ]]; then
55+
NEXT_INDEX=$((CURRENT_ALPHA_NUM + 1))
56+
NEXT_VERSION="$BASE_VERSION-alpha.$NEXT_INDEX"
57+
echo "Same base version detected. Incrementing alpha to: $NEXT_VERSION"
58+
else
59+
NEXT_VERSION="$BASE_VERSION-alpha.0"
60+
echo "New base version detected. Resetting alpha to: $NEXT_VERSION"
61+
fi
62+
fi
63+
64+
echo "Updating package.json"
65+
npm version $NEXT_VERSION --no-git-tag-version
66+
67+
- name: Build module
68+
run: npm run build
69+
70+
- name: Publish to npm
71+
run: npm publish --tag alpha
72+
env:
73+
NODE_AUTH_TOKEN: ${{ secrets.ALPHA_NPM_TOKEN }}

0 commit comments

Comments
 (0)