-
-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (76 loc) · 2.55 KB
/
npm-publish.yml
File metadata and controls
88 lines (76 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Publish npm Package
on:
release:
types: [published]
workflow_dispatch:
inputs:
registry:
description: 'Registry to publish to'
required: true
default: 'github'
type: choice
options:
- github
- npmjs
jobs:
build-and-publish:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
packages: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: temurin
cache: sbt
- name: Set up SBT
uses: sbt/setup-sbt@v1
- name: Coursier Caching
uses: coursier/cache-action@v6
- name: Configure sbt GitHub Packages credentials
run: |
mkdir -p ~/.sbt/1.0
cat > ~/.sbt/1.0/github.sbt << 'EOF'
credentials += Credentials(
"GitHub Package Registry",
"maven.pkg.github.com",
"x-access-token",
sys.env.getOrElse("GITHUB_TOKEN", "")
)
EOF
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Publish to GitHub Packages
if: github.event_name == 'release' || github.event.inputs.registry == 'github'
run: sbt --batch riddlLibJS/npmPublishGithub
- name: Publish to npmjs.com
if: github.event.inputs.registry == 'npmjs'
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: sbt --batch riddlLibJS/npmPublishNpmjs
- name: Get version for summary
id: version
run: |
VERSION=$(sbt --batch "print riddlLibJS/version" 2>/dev/null | grep -v "\[info\]" | grep -v "loading" | tail -1 | tr -d ' ')
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Generate summary
run: |
echo "## npm Package Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Package:** \`@ossuminc/riddl-lib\`" >> $GITHUB_STEP_SUMMARY
echo "**Version:** \`${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Installation" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
echo "npm install @ossuminc/riddl-lib" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY