Skip to content

Commit 8f05f22

Browse files
committed
Added support for CI releases
1 parent 87c1e38 commit 8f05f22

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

.github/workflows/ci.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ on:
1212
branches: ['**']
1313
push:
1414
branches: ['**']
15+
tags: [v*]
1516

1617
env:
1718
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
20+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
21+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
1822

1923
jobs:
2024
build:
@@ -63,3 +67,85 @@ jobs:
6367
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
6468

6569
- run: sbt ++${{ matrix.scala }} '${{ matrix.ci }}'
70+
71+
- name: Compress target directories
72+
run: tar cf targets.tar target root/target core/target webworker/target project/target
73+
74+
- name: Upload target directories
75+
uses: actions/upload-artifact@v2
76+
with:
77+
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
78+
path: targets.tar
79+
80+
publish:
81+
name: Publish Artifacts
82+
needs: [build]
83+
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
84+
strategy:
85+
matrix:
86+
os: [ubuntu-latest]
87+
scala: [3.0.1]
88+
java: [adopt@1.8]
89+
runs-on: ${{ matrix.os }}
90+
steps:
91+
- name: Checkout current branch (full)
92+
uses: actions/checkout@v2
93+
with:
94+
fetch-depth: 0
95+
96+
- name: Setup Java and Scala
97+
uses: olafurpg/setup-scala@v13
98+
with:
99+
java-version: ${{ matrix.java }}
100+
101+
- name: Cache sbt
102+
uses: actions/cache@v2
103+
with:
104+
path: |
105+
~/.sbt
106+
~/.ivy2/cache
107+
~/.coursier/cache/v1
108+
~/.cache/coursier/v1
109+
~/AppData/Local/Coursier/Cache/v1
110+
~/Library/Caches/Coursier/v1
111+
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
112+
113+
- name: Download target directories (2.12.14)
114+
uses: actions/download-artifact@v2
115+
with:
116+
name: target-${{ matrix.os }}-2.12.14-${{ matrix.java }}
117+
118+
- name: Inflate target directories (2.12.14)
119+
run: |
120+
tar xf targets.tar
121+
rm targets.tar
122+
123+
- name: Download target directories (2.13.6)
124+
uses: actions/download-artifact@v2
125+
with:
126+
name: target-${{ matrix.os }}-2.13.6-${{ matrix.java }}
127+
128+
- name: Inflate target directories (2.13.6)
129+
run: |
130+
tar xf targets.tar
131+
rm targets.tar
132+
133+
- name: Download target directories (3.0.1)
134+
uses: actions/download-artifact@v2
135+
with:
136+
name: target-${{ matrix.os }}-3.0.1-${{ matrix.java }}
137+
138+
- name: Inflate target directories (3.0.1)
139+
run: |
140+
tar xf targets.tar
141+
rm targets.tar
142+
143+
- name: Import signing key
144+
run: echo $PGP_SECRET | base64 -d | gpg --import
145+
146+
- name: Hack pinentry to use PGP_PASSPHRASE
147+
env:
148+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
149+
run: echo "$PGP_PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 build.sbt &> /dev/null
150+
151+
- run: sbt ++${{ matrix.scala }} release

build.sbt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ ThisBuild / scmInfo := Some(
4040
url("https://github.com/scala-js/scala-js-macrotask-executor"),
4141
"git@github.com:scala-js/scala-js-macrotask-executor.git"))
4242

43+
// build and matrix configuration
44+
4345
ThisBuild / crossScalaVersions := Seq("2.12.14", "2.13.6", "3.0.1")
4446

4547
ThisBuild / githubWorkflowBuildPreamble ++= Seq(
@@ -66,6 +68,21 @@ addCommandAlias("ciFirefox", "; set useJSEnv := JSEnv.Firefox; all core/test web
6668
addCommandAlias("ciChrome", "; set useJSEnv := JSEnv.Chrome; all core/test webworker/test; set useJSEnv := JSEnv.NodeJS")
6769
addCommandAlias("ciJSDOMNodeJS", "; set useJSEnv := JSEnv.JSDOMNodeJS; core/test; set useJSEnv := JSEnv.NodeJS")
6870

71+
// release configuration
72+
73+
enablePlugins(SonatypeCiReleasePlugin)
74+
75+
ThisBuild / spiewakMainBranches := Seq("main")
76+
77+
// we can remove this once we have a non-password-protected key in the secrets
78+
ThisBuild / githubWorkflowPublishPreamble +=
79+
WorkflowStep.Run(
80+
List("echo \"$PGP_PASSPHRASE\" | gpg --batch --yes --passphrase-fd 0 build.sbt &> /dev/null"),
81+
name = Some("Hack pinentry to use PGP_PASSPHRASE"),
82+
env = Map("PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}"))
83+
84+
// environments
85+
6986
lazy val useJSEnv =
7087
settingKey[JSEnv]("Use Node.js or a headless browser for running Scala.js tests")
7188

@@ -105,6 +122,8 @@ ThisBuild / Test / jsEnv := {
105122
}
106123
}
107124

125+
// project structure
126+
108127
lazy val root = project
109128
.aggregate(core, webworker)
110129
.enablePlugins(NoPublishPlugin)

0 commit comments

Comments
 (0)