44 pull_request :
55 push :
66 branches : ['version-1.*.x']
7- workflow_dispatch :
8- inputs :
9- version :
10- description : Version
11- required : true
12- tag :
13- description : Tag
14- required : true
15- default : snapshot
167 release :
178 types : [published]
189
@@ -24,41 +15,39 @@ jobs:
2415 contents : read
2516 attestations : write
2617 id-token : write
27- env :
28- PR_NUMBER : ${{ github.event.number }}
2918 steps :
3019 - uses : actions/checkout@v4
31- - if : ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'publish-snapshots') }}
32- env :
33- RUN_NUMBER : ${{ github.run_number }}
34- RUN_ATTEMPT : ${{ github.run_attempt }}
35- PR_NUMBER : ${{ github.event.number }}
36- run : |
37- echo "VERSION=$(awk -F '[".]' '{print $3"."$4"."$5+1}' version.sbt)-$PR_NUMBER-snapshot.$RUN_NUMBER.$RUN_ATTEMPT" >> $GITHUB_ENV
38- echo "TAG=snapshot" >> $GITHUB_ENV
39- - if : ${{ github.event_name == 'workflow_dispatch' }}
40- run : |
41- echo "VERSION=${{ inputs.version }}" >> $GITHUB_ENV
42- echo "TAG=${{ inputs.tag }}" >> $GITHUB_ENV
43- - if : ${{ github.event_name == 'release' }}
44- run : |
45- VERSION=$(echo ${{ github.release.tag_name }} | sed 's/^v//')
46- echo "VERSION=$VERSION >> $GITHUB_ENV
47- echo "TAG=latest" >> $GITHUB_ENV
48- - if : ${{ github.event_name == 'push' }}
49- run : |
50- echo "VERSION=$(awk -F '[".]' '{print $3"."$4"."$5+1}' version.sbt)-snapshot.$RUN_NUMBER.$RUN_ATTEMPT" >> $GITHUB_ENV
51- echo "TAG=snapshot" >> $GITHUB_ENV
20+ - uses : proudust/gh-describe@70f72d4f6304ea053cf5a3d71c36211d5acc0c73
21+ id : ghd
5222 - uses : actions/setup-java@v4
5323 with :
5424 distribution : ' temurin'
5525 java-version : ' 11'
5626 cache : ' sbt'
5727 - uses : sbt/setup-sbt@v1
58- - run : sbt --batch ';lang-tests/test;lang-tests-js/test;repl/test;langJS/fullOptJS;replJS/fullOptJS'
28+ - run : sbt -Dproject.version=${{ steps.ghd.outputs.describe }} - -batch ';lang-tests/test;lang-tests-js/test;repl/test;langJS/fullOptJS;replJS/fullOptJS'
5929 - uses : actions/setup-node@v4
6030 with :
6131 registry-url : ' https://registry.npmjs.org'
32+ - if : ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
33+ run : |
34+ SBT_VERSION=$(awk -F '[".]' '{print $3"."$4"."$5+1}' version.sbt)
35+ PACKAGE_NAME=$(jq --raw-output .name lang/js/package.json)
36+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
37+ PREID="${{ github.event.number }}-snapshot"
38+ else
39+ PREID="snapshot"
40+ fi
41+ npm version prerelease --preid=$PREID --no-git-tag-version
42+ PREFIX=$SBT_VERSION-$PREID
43+ NEXT=$(npm view $PACKAGE_NAME versions --json \
44+ | jq --raw-output --arg prefix $PREFIX '[.[] | select(startswith($prefix))|capture("snapshot\\.(?<n>[0-9]+)").n|tonumber]|max + 1 // 0')
45+ echo "VERSION=$PREFIX-$NEXT" >> $GITHUB_ENV
46+ echo "TAG=snapshot" >> $GITHUB_ENV
47+ - if : ${{ github.event_name == 'release' }}
48+ run : |
49+ echo "VERSION=$(echo ${{ github.release.tag_name }} | sed 's/^v//')" >> $GITHUB_ENV
50+ echo "TAG=latest" >> $GITHUB_ENV
6251 - run : |
6352 cd lang/js
6453 npm version $VERSION --no-git-tag-version
0 commit comments