Skip to content

Commit 6fed501

Browse files
Jose AngelJose Angel
authored andcommitted
ci: implement branch-based release strategy
- Workflows now trigger on develop branch and v* tags only - develop branch: publishes dev/snapshot versions - Python: X.Y.Z.devN - Java: X.Y.Z-SNAPSHOT - JavaScript: X.Y.Z-dev.N (npm tag: dev) - v* tags: publishes stable releases to PyPI, Maven Central, npm - Updated GitHub Actions to latest versions (checkout@v4, etc.)
1 parent 082320c commit 6fed501

3 files changed

Lines changed: 83 additions & 23 deletions

File tree

.github/workflows/java.yml

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,66 @@
11
name: Build and Deploy Java Parser
22

33
on:
4-
push
4+
push:
5+
branches: [develop]
6+
tags: ['v*']
57

68
jobs:
79
build:
810
runs-on: ubuntu-latest
911

1012
steps:
1113
- name: Checkout code
12-
uses: actions/checkout@v2
14+
uses: actions/checkout@v4
1315

1416
- name: Install ANTLR4 and Maven
1517
run: |
16-
# Add installation steps for ANTLR4 here
1718
sudo apt-get update
1819
sudo apt-get install -y maven
1920
make dev
2021
2122
- name: Import GPG key
22-
uses: crazy-max/ghaction-import-gpg@v1
23-
env:
24-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
25-
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
26-
23+
uses: crazy-max/ghaction-import-gpg@v6
24+
with:
25+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
26+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
27+
28+
- name: Set SNAPSHOT version (develop branch)
29+
if: github.ref == 'refs/heads/develop'
30+
run: |
31+
cd java
32+
BASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//')
33+
mvn versions:set -DnewVersion="${BASE_VERSION}-SNAPSHOT" -DgenerateBackupPoms=false
34+
35+
- name: Set release version (tag)
36+
if: startsWith(github.ref, 'refs/tags/v')
37+
run: |
38+
cd java
39+
TAG_VERSION=${GITHUB_REF_NAME#v}
40+
mvn versions:set -DnewVersion="${TAG_VERSION}" -DgenerateBackupPoms=false
41+
2742
- name: Generate and Compile Java Code
2843
run: make java_parser
2944

3045
- name: Cache Maven packages
31-
uses: actions/cache@v2
46+
uses: actions/cache@v4
3247
with:
3348
path: ~/.m2
3449
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
3550
restore-keys: ${{ runner.os }}-m2
3651

37-
- name: Deploy to Maven Central
52+
- name: Deploy SNAPSHOT to OSSRH (develop branch)
53+
if: github.ref == 'refs/heads/develop'
54+
run: cd java && mvn clean deploy --settings ../.github/settings.xml
55+
env:
56+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
57+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
58+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
59+
60+
- name: Deploy Release to Maven Central (tag)
61+
if: startsWith(github.ref, 'refs/tags/v')
3862
run: cd java && mvn clean deploy --settings ../.github/settings.xml
3963
env:
4064
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
4165
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
42-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
66+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

.github/workflows/js.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
name: Build and Deploy JS Parser
22

33
on:
4-
push
4+
push:
5+
branches: [develop]
6+
tags: ['v*']
57

68
jobs:
79
build:
810
runs-on: ubuntu-latest
911

1012
steps:
1113
- name: Checkout code
12-
uses: actions/checkout@v2
14+
uses: actions/checkout@v4
1315

1416
- name: Setup Node
15-
uses: actions/setup-node@v1
17+
uses: actions/setup-node@v4
1618
with:
17-
node-version: 19
18-
registry-url: https://registry.npmjs.org/
19-
19+
node-version: 20
20+
registry-url: https://registry.npmjs.org/
21+
2022
- name: Install ANTLR4
2123
run: |
2224
make dev
@@ -25,7 +27,23 @@ jobs:
2527
- name: Generate and Build Node Code
2628
run: cd js && npm install && npm run build-grammar
2729

28-
- name: Publish npm package
29-
run: cd js && npm publish --access public
30+
- name: Set dev version and publish (develop branch)
31+
if: github.ref == 'refs/heads/develop'
32+
run: |
33+
cd js
34+
npm version --no-git-tag-version "$(node -p "require('./package.json').version")-dev.${GITHUB_RUN_NUMBER}"
35+
echo "Publishing version: $(node -p "require('./package.json').version")"
36+
npm publish --tag dev --access public
37+
env:
38+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
39+
40+
- name: Set release version and publish (tag)
41+
if: startsWith(github.ref, 'refs/tags/v')
42+
run: |
43+
cd js
44+
TAG_VERSION=${GITHUB_REF_NAME#v}
45+
npm version --no-git-tag-version "${TAG_VERSION}"
46+
echo "Publishing version: ${TAG_VERSION}"
47+
npm publish --access public
3048
env:
31-
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
49+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

.github/workflows/python.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
name: Build and Deploy Python Parser
22

33
on:
4-
push
4+
push:
5+
branches: [develop]
6+
tags: ['v*']
57

68
jobs:
79
build:
810
runs-on: ubuntu-latest
911

1012
steps:
1113
- name: Checkout code
12-
uses: actions/checkout@v2
14+
uses: actions/checkout@v4
1315

1416
- name: Install ANTLR4 and Python dependencies
1517
run: |
16-
# Add installation steps for ANTLR4 here
1718
sudo apt-get update
1819
sudo apt-get install -y python3 python3-pip
1920
make dev
2021
2122
- name: Generate and Build Python Code
2223
run: make python_parser
2324

25+
- name: Set dev version (develop branch)
26+
if: github.ref == 'refs/heads/develop'
27+
run: |
28+
cd python
29+
BASE_VERSION=$(grep -oP 'version="\K[0-9]+\.[0-9]+\.[0-9]+' setup.py)
30+
DEV_VERSION="${BASE_VERSION}.dev${GITHUB_RUN_NUMBER}"
31+
sed -i "s/version=\"[^\"]*\"/version=\"${DEV_VERSION}\"/" setup.py
32+
echo "Publishing version: ${DEV_VERSION}"
33+
34+
- name: Set release version (tag)
35+
if: startsWith(github.ref, 'refs/tags/v')
36+
run: |
37+
cd python
38+
TAG_VERSION=${GITHUB_REF_NAME#v}
39+
sed -i "s/version=\"[^\"]*\"/version=\"${TAG_VERSION}\"/" setup.py
40+
echo "Publishing version: ${TAG_VERSION}"
41+
2442
- name: Build and publish python package
2543
env:
2644
TWINE_USERNAME: __token__

0 commit comments

Comments
 (0)