Skip to content

Commit 76f3939

Browse files
committed
Add GitHub Actions workflow for publishing alpha version of podverse-parser
1 parent 959fc9e commit 76f3939

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Publish Alpha podverse-parser
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: Install podverse-external-services latest alpha version
27+
run: |
28+
npm i podverse-external-services@alpha --save
29+
30+
- name: Install podverse-orm latest alpha version
31+
run: |
32+
npm i podverse-orm@alpha --save
33+
34+
- name: Clean install dependencies
35+
run: npm clean-install
36+
37+
- name: Increment alpha version
38+
id: version
39+
run: |
40+
PACKAGE_NAME=$(node -p "require('./package.json').name")
41+
BASE_VERSION=$(node -p "require('./package.json').version")
42+
# Strip any pre-release tag (e.g., '-develop') from BASE_VERSION
43+
BASE_VERSION=$(echo "$BASE_VERSION" | sed 's/-.*//')
44+
45+
# Try to get the current alpha version (e.g., 5.1.1-alpha.3)
46+
ALPHA_VERSION=$(npm dist-tag ls "$PACKAGE_NAME" 2>/dev/null | grep -w alpha | awk '{print $2}')
47+
48+
# If no alpha tag exists
49+
if [[ -z "$ALPHA_VERSION" ]]; then
50+
echo "No alpha version found. Starting with: $BASE_VERSION-alpha.0"
51+
NEXT_VERSION="$BASE_VERSION-alpha.0"
52+
else
53+
# Extract the base and numeric suffix from the current alpha version
54+
CURRENT_BASE=$(echo "$ALPHA_VERSION" | cut -d '-' -f 1)
55+
CURRENT_ALPHA_NUM=$(echo "$ALPHA_VERSION" | sed -En 's/.*alpha\.([0-9]+)$/\1/p')
56+
57+
# If current alpha is malformed or suffix missing
58+
if [[ -z "$CURRENT_ALPHA_NUM" ]]; then
59+
NEXT_VERSION="$BASE_VERSION-alpha.0"
60+
fi
61+
62+
if [[ "$CURRENT_BASE" == "$BASE_VERSION" ]]; then
63+
NEXT_INDEX=$((CURRENT_ALPHA_NUM + 1))
64+
NEXT_VERSION="$BASE_VERSION-alpha.$NEXT_INDEX"
65+
echo "Same base version detected. Incrementing alpha to: $NEXT_VERSION"
66+
else
67+
NEXT_VERSION="$BASE_VERSION-alpha.0"
68+
echo "New base version detected. Resetting alpha to: $NEXT_VERSION"
69+
fi
70+
fi
71+
72+
echo "Updating package.json"
73+
npm version $NEXT_VERSION --no-git-tag-version
74+
75+
- name: Build module
76+
run: npm run build
77+
78+
- name: Publish to npm
79+
run: npm publish --tag alpha
80+
env:
81+
NODE_AUTH_TOKEN: ${{ secrets.ALPHA_NPM_TOKEN }}

0 commit comments

Comments
 (0)