Skip to content

Commit 321fdb2

Browse files
committed
wip
1 parent a26f9ec commit 321fdb2

File tree

2 files changed

+41
-33
lines changed

2 files changed

+41
-33
lines changed

.github/workflows/publish-nodejs-packages.yml

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ on:
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

lang/tests/src/test/scala/com/wavesplatform/utils/RSATest.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,25 @@ class RSATest extends PropSpec with BeforeAndAfterAll {
324324
PureContext.build(V3, useNewPowPrecision = true) |+| CryptoContext.build(Global, V3, true)
325325
) shouldBe Right(CONST_BOOLEAN(true))
326326
}
327+
328+
property("test all hashes") {
329+
val message = "hello world".getBytes()
330+
val keyPair = keyPairGenerator.sample.get
331+
val xpub = keyPair.getPublic
332+
val xprv = keyPair.getPrivate
333+
println(s"PUB=${Base64.encode(xpub.getEncoded)}")
334+
println(s"MSG=${Base64.encode(message)}")
335+
algs.foreach { alg =>
336+
val prefix = RSA.digestAlgorithmPrefix(alg)
337+
338+
val privateSignature = Signature.getInstance(s"${prefix}withRSA", provider)
339+
privateSignature.initSign(xprv)
340+
privateSignature.update(message)
341+
342+
val signature = privateSignature.sign
343+
println(s"$alg=${Base64.encode(signature)}")
344+
}
345+
}
327346

328347
property("sign from scala") {
329348
val message = "hello world".getBytes()

0 commit comments

Comments
 (0)