Skip to content

Commit 45ab010

Browse files
committed
refactor(build): demo zio-sbt pr 440 changes
1 parent b7795b8 commit 45ab010

File tree

7 files changed

+377
-535
lines changed

7 files changed

+377
-535
lines changed

.github/workflows/ci.yml

+230-98
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,267 @@
1-
name: CI
1+
# This file was autogenerated using `zio-sbt-ci` plugin via `sbt ciGenerateGithubWorkflow`
2+
# task and should be included in the git repository. Please do not edit it manually.
23

4+
name: CI
35
env:
4-
JDK_JAVA_OPTIONS: -XX:+PrintCommandLineFlags # JDK_JAVA_OPTIONS is _the_ env. variable to use for modern Java
5-
JVM_OPTS: -XX:+PrintCommandLineFlags # for Java 8 only (sadly, it is not modern enough for JDK_JAVA_OPTIONS)
6-
7-
on:
8-
pull_request:
9-
push:
10-
branches: ['series/2.x']
6+
JDK_JAVA_OPTIONS: -XX:+PrintCommandLineFlags
7+
'on':
8+
workflow_dispatch: {}
119
release:
1210
types:
1311
- published
14-
12+
pull_request:
13+
branches-ignore:
14+
- gh-pages
15+
push:
16+
branches:
17+
- series/2.x
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.run_id || github.ref }}
20+
cancel-in-progress: true
1521
jobs:
16-
lint:
17-
runs-on: ubuntu-20.04
18-
timeout-minutes: 30
22+
build:
23+
name: Build
24+
runs-on: ubuntu-latest
25+
continue-on-error: true
1926
steps:
20-
- name: Checkout current branch
21-
uses: actions/checkout@v4.1.2
27+
- name: Git Checkout
28+
uses: actions/checkout@v4
2229
with:
23-
fetch-depth: 0
24-
- name: Setup Java
25-
uses: actions/[email protected]
30+
fetch-depth: '0'
31+
- name: Install libuv
32+
run: sudo apt-get update && sudo apt-get install -y libuv1-dev
33+
- name: Setup Scala
34+
uses: actions/setup-java@v4
2635
with:
27-
distribution: temurin
28-
java-version: 21
29-
check-latest: true
30-
- name: Cache scala dependencies
36+
distribution: corretto
37+
java-version: '17'
38+
check-latest: 'true'
39+
- name: Cache Dependencies
3140
uses: coursier/cache-action@v6
32-
- name: Lint code
33-
run: sbt check
34-
35-
benchmarks:
36-
runs-on: ubuntu-20.04
37-
strategy:
38-
fail-fast: false
39-
matrix:
40-
java: ['17', '21']
41-
scala: ['2.13.15']
41+
- name: Check all code compiles
42+
run: sbt +Test/compile
43+
- name: Check artifacts build process
44+
run: sbt +publishLocal
45+
- name: Check website build process
46+
run: sbt docs/clean; sbt docs/buildWebsite
47+
lint:
48+
name: Lint
49+
runs-on: ubuntu-latest
50+
continue-on-error: false
4251
steps:
43-
- name: Checkout current branch
44-
uses: actions/checkout@v4.1.2
52+
- name: Git Checkout
53+
uses: actions/checkout@v4
4554
with:
46-
fetch-depth: 0
47-
- name: Setup Java
48-
uses: actions/[email protected]
55+
fetch-depth: '0'
56+
- name: Install libuv
57+
run: sudo apt-get update && sudo apt-get install -y libuv1-dev
58+
- name: Setup Scala
59+
uses: actions/setup-java@v4
4960
with:
50-
distribution: temurin
51-
java-version: ${{ matrix.java }}
52-
check-latest: true
53-
- name: Cache scala dependencies
61+
distribution: corretto
62+
java-version: '17'
63+
check-latest: 'true'
64+
- name: Cache Dependencies
5465
uses: coursier/cache-action@v6
55-
- name: Compile benchmarks
56-
run: sbt ++${{ matrix.scala }}! jmh:compile
57-
58-
mdoc:
59-
runs-on: ubuntu-20.04
60-
timeout-minutes: 60
61-
steps:
62-
- name: Checkout current branch
63-
uses: actions/[email protected]
64-
- name: Setup Java
65-
uses: actions/[email protected]
66-
with:
67-
distribution: temurin
68-
java-version: 8
69-
check-latest: true
70-
- name: Cache scala dependencies
71-
uses: coursier/cache-action@v6
72-
- name: Check Document Generation
73-
run: sbt compileDocs
74-
66+
- name: Check if the site workflow is up to date
67+
run: sbt ciCheckGithubWorkflow
68+
- name: Lint
69+
run: sbt lint
7570
test:
76-
runs-on: ubuntu-20.04
77-
timeout-minutes: 30
71+
name: Test
72+
runs-on: ubuntu-latest
73+
continue-on-error: false
7874
strategy:
79-
fail-fast: false
8075
matrix:
81-
java: ['17', '21']
82-
scala: ['2.12.19', '2.13.15', '3.3.4']
83-
platform: ['JVM', 'JS', 'Native']
76+
java:
77+
- '11'
78+
- '17'
79+
- '21'
80+
scalaVersion:
81+
- 2.12.20
82+
- 2.13.15
83+
- 3.3.4
84+
scalaPlatform:
85+
- JS
86+
- JVM
87+
- Native
88+
fail-fast: false
8489
steps:
85-
- name: Checkout current branch
86-
uses: actions/[email protected]
87-
with:
88-
fetch-depth: 0
89-
- name: Setup Java
90-
uses: actions/[email protected]
90+
- name: Install libuv
91+
run: sudo apt-get update && sudo apt-get install -y libuv1-dev
92+
- name: Setup Scala
93+
uses: actions/setup-java@v4
9194
with:
92-
distribution: temurin
95+
distribution: corretto
9396
java-version: ${{ matrix.java }}
94-
check-latest: true
95-
- name: Cache scala dependencies
97+
check-latest: 'true'
98+
- name: Cache Dependencies
9699
uses: coursier/cache-action@v6
100+
- name: Git Checkout
101+
uses: actions/checkout@v4
102+
with:
103+
fetch-depth: '0'
104+
- name: Test
105+
run: sbt +test${{ matrix.scalaPlatform }}${{ startsWith(matrix.scalaVersion, '2.12') && '2_12' || (startsWith(matrix.scalaVersion, '2.13') && '2_13' || (startsWith(matrix.scalaVersion, '3') && '3' || '')) }}
106+
update-readme:
107+
name: Update README
108+
runs-on: ubuntu-latest
109+
continue-on-error: false
110+
if: ${{ github.event_name == 'push' }}
111+
steps:
112+
- name: Git Checkout
113+
uses: actions/checkout@v4
114+
with:
115+
fetch-depth: '0'
97116
- name: Install libuv
98-
if: matrix.platform == 'Native'
99117
run: sudo apt-get update && sudo apt-get install -y libuv1-dev
100-
- name: Run Macros tests
101-
if: ${{ !startsWith(matrix.scala, '3.3.') }}
102-
run: sbt ++${{ matrix.scala }}! testScala2${{ matrix.platform }}
103-
- name: Run tests
104-
run: sbt ++${{ matrix.scala }}! test${{ matrix.platform }}
118+
- name: Setup Scala
119+
uses: actions/setup-java@v4
120+
with:
121+
distribution: corretto
122+
java-version: '17'
123+
check-latest: 'true'
124+
- name: Cache Dependencies
125+
uses: coursier/cache-action@v6
126+
- name: Generate Readme
127+
run: sbt docs/generateReadme
128+
- name: Commit Changes
129+
run: |
130+
git config --local user.email "zio-assistant[bot]@users.noreply.github.com"
131+
git config --local user.name "ZIO Assistant"
132+
git add README.md
133+
git commit -m "Update README.md" || echo "No changes to commit"
134+
- name: Generate Token
135+
id: generate-token
136+
137+
with:
138+
app_id: ${{ secrets.APP_ID }}
139+
app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
140+
- name: Create Pull Request
141+
id: cpr
142+
uses: peter-evans/create-pull-request@v6
143+
with:
144+
body: |-
145+
Autogenerated changes after running the `sbt docs/generateReadme` command of the [zio-sbt-website](https://zio.dev/zio-sbt) plugin.
105146
147+
I will automatically update the README.md file whenever there is new change for README.md, e.g.
148+
- After each release, I will update the version in the installation section.
149+
- After any changes to the "docs/index.md" file, I will update the README.md file accordingly.
150+
branch: zio-sbt-website/update-readme
151+
commit-message: Update README.md
152+
token: ${{ steps.generate-token.outputs.token }}
153+
delete-branch: 'true'
154+
title: Update README.md
155+
- name: Approve PR
156+
if: ${{ steps.cpr.outputs.pull-request-number }}
157+
run: gh pr review "$PR_URL" --approve
158+
env:
159+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160+
PR_URL: ${{ steps.cpr.outputs.pull-request-url }}
161+
- name: Enable Auto-Merge
162+
if: ${{ steps.cpr.outputs.pull-request-number }}
163+
run: gh pr merge --auto --squash "$PR_URL" || gh pr merge --squash "$PR_URL"
164+
env:
165+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
166+
PR_URL: ${{ steps.cpr.outputs.pull-request-url }}
106167
ci:
107-
runs-on: ubuntu-20.04
108-
needs: [lint, mdoc, benchmarks, test]
168+
name: ci
169+
runs-on: ubuntu-latest
170+
continue-on-error: false
171+
needs:
172+
- lint
173+
- test
174+
- build
109175
steps:
110-
- name: Aggregate of lint, and all tests
176+
- name: Report Successful CI
111177
run: echo "ci passed"
112-
113-
publish:
114-
runs-on: ubuntu-20.04
115-
timeout-minutes: 60
116-
needs: [ci]
117-
if: github.event_name != 'pull_request'
178+
release:
179+
name: Release
180+
runs-on: ubuntu-latest
181+
continue-on-error: false
182+
needs:
183+
- ci
184+
if: ${{ github.event_name != 'pull_request' }}
118185
steps:
119-
- name: Checkout current branch
120-
uses: actions/checkout@v4.1.2
186+
- name: Git Checkout
187+
uses: actions/checkout@v4
121188
with:
122-
fetch-depth: 0
123-
- name: Setup Java
124-
uses: actions/[email protected]
189+
fetch-depth: '0'
190+
- name: Install libuv
191+
run: sudo apt-get update && sudo apt-get install -y libuv1-dev
192+
- name: Setup Scala
193+
uses: actions/setup-java@v4
125194
with:
126-
distribution: temurin
127-
java-version: 8
128-
check-latest: true
195+
distribution: corretto
196+
java-version: '17'
197+
check-latest: 'true'
198+
- name: Cache Dependencies
199+
uses: coursier/cache-action@v6
129200
- name: Release
130201
run: sbt ci-release
131202
env:
132203
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
133204
PGP_SECRET: ${{ secrets.PGP_SECRET }}
134205
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
135206
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
207+
CI_RELEASE: +publishSigned
208+
CI_SNAPSHOT_RELEASE: +publish
209+
release-docs:
210+
name: Release Docs
211+
runs-on: ubuntu-latest
212+
continue-on-error: false
213+
needs:
214+
- release
215+
if: ${{ ((github.event_name == 'release') && (github.event.action == 'published')) || (github.event_name == 'workflow_dispatch') }}
216+
steps:
217+
- name: Git Checkout
218+
uses: actions/checkout@v4
219+
with:
220+
fetch-depth: '0'
221+
- name: Install libuv
222+
run: sudo apt-get update && sudo apt-get install -y libuv1-dev
223+
- name: Setup Scala
224+
uses: actions/setup-java@v4
225+
with:
226+
distribution: corretto
227+
java-version: '17'
228+
check-latest: 'true'
229+
- name: Cache Dependencies
230+
uses: coursier/cache-action@v6
231+
- name: Setup NodeJs
232+
uses: actions/setup-node@v4
233+
with:
234+
node-version: 16.x
235+
registry-url: https://registry.npmjs.org
236+
- name: Publish Docs to NPM Registry
237+
run: sbt docs/publishToNpm
238+
env:
239+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
240+
notify-docs-release:
241+
name: Notify Docs Release
242+
runs-on: ubuntu-latest
243+
continue-on-error: false
244+
needs:
245+
- release-docs
246+
if: ${{ (github.event_name == 'release') && (github.event.action == 'published') }}
247+
steps:
248+
- name: Git Checkout
249+
uses: actions/checkout@v4
250+
with:
251+
fetch-depth: '0'
252+
- name: notify the main repo about the new release of docs package
253+
run: |
254+
PACKAGE_NAME=$(cat docs/package.json | grep '"name"' | awk -F'"' '{print $4}')
255+
PACKAGE_VERSION=$(npm view $PACKAGE_NAME version)
256+
curl -L \
257+
-X POST \
258+
-H "Accept: application/vnd.github+json" \
259+
-H "Authorization: token ${{ secrets.PAT_TOKEN }}"\
260+
https://api.github.com/repos/zio/zio/dispatches \
261+
-d '{
262+
"event_type":"update-docs",
263+
"client_payload":{
264+
"package_name":"'"${PACKAGE_NAME}"'",
265+
"package_version": "'"${PACKAGE_VERSION}"'"
266+
}
267+
}'

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The goal of this project is to create the best all-round JSON library for Scala:
2525
In order to use this library, we need to add the following line in our `build.sbt` file:
2626

2727
```scala
28-
libraryDependencies += "dev.zio" %% "zio-json" % "0.6.2"
28+
libraryDependencies += "dev.zio" %% "zio-json" % "0.7.0"
2929
```
3030

3131
## Example

0 commit comments

Comments
 (0)