Skip to content

Commit 8ff2b3b

Browse files
committed
Update library author guide to use the latest actions/setup-java
Also fix a few typos
1 parent 9633737 commit 8ff2b3b

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

_overviews/contributors/index.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ that the license and copyright notices are preserved. For the record, Scala itse
2222

2323
Once you have chosen a license, *apply* it to your project by creating a `LICENSE` file in the root directory
2424
of your project with the license contents or a link to it. This file usually indicates who owns the copyright.
25-
In our example of [LICENSE file](https://github.com/scalacenter/library-example/blob/master/LICENSE), we have
25+
In our example of [LICENSE file](https://github.com/scalacenter/library-example/blob/main/LICENSE), we have
2626
written that all the contributors (as per the Git log) own the copyright.
2727

2828
## Host the Source Code
@@ -31,15 +31,15 @@ We recommend sharing the source code of your library by hosting it on a public [
3131
hosting site such as [GitHub](https://github.com), [Bitbucket](https://bitbucket.org) or [GitLab](https://gitlab.com).
3232
In our example, we use GitHub.
3333

34-
Your project should include a [README](https://github.com/scalacenter/library-example/blob/master/README.md) file
34+
Your project should include a [README](https://github.com/scalacenter/library-example/blob/main/README.md) file
3535
including a description of what the library does and some documentation (or links to the documentation).
3636

3737
You should take care of putting only source files under version control. For instance, artifacts generated by the
3838
build system should *not* be versioned. You can instruct Git to ignore such files by adding them to a
39-
[.gitignore](https://github.com/scalacenter/library-example/blob/master/.gitignore) file.
39+
[.gitignore](https://github.com/scalacenter/library-example/blob/main/.gitignore) file.
4040

4141
In case you are using sbt, make sure your repository has a
42-
[project/build.properties](https://github.com/scalacenter/library-example/blob/master/project/build.properties)
42+
[project/build.properties](https://github.com/scalacenter/library-example/blob/main/project/build.properties)
4343
file indicating the sbt version to use, so that people (or tools) working on your repository will automatically
4444
use the correct sbt version.
4545

@@ -71,32 +71,35 @@ jobs:
7171
ci:
7272
runs-on: ubuntu-latest
7373
steps:
74-
- uses: actions/checkout@v2 # Retrieve the content of the repository
75-
- uses: actions/setup-java@v2 # Set up a jdk
74+
- uses: actions/checkout@v3 # Retrieve the content of the repository
75+
- uses: actions/setup-java@v3 # Set up a jdk
7676
with:
7777
distribution: temurin
7878
java-version: 8
79+
cache: sbt # Cache the artifacts downloaded by sbt accross CI runs
7980
- name: unit tests # Custom action consisting of a shell command
8081
run: sbt +test
8182
~~~
8283

8384
This workflow is called *Continuous integration* and it will run every time one
8485
or more commits are pushed to the repository. It contains only one job called
8586
*ci*, which will run on an Ubuntu runner and that is composed of three
86-
actions. The action `setup-scala` installs the sbt launcher in the runner. Then
87-
the job runs `sbt +test`, which loads the sbt version specified in
87+
actions. The action `setup-java` installs a JDK and caches the library dependencies
88+
downloaded by sbt so that they are not downloaded again everytime the CI runs.
89+
90+
Then, the job runs `sbt +test`, which loads the sbt version specified in
8891
`project/build.properties`, and runs the project tests using the Scala version
8992
defined in the file `build.sbt`.
9093

9194
The workflow above will run at any push to any branch of the repository. You
9295
can specify the branch or add more triggers such as pull requests, releases,
9396
tags or schedules. More information about workflow triggers is available
9497
[here](https://docs.github.com/en/actions/reference/events-that-trigger-workflows).
95-
while the `setup-scala` action is hosted [in this
96-
repository](https://github.com/olafurpg/setup-scala).
98+
while the `setup-java` action is hosted [in this
99+
repository](https://github.com/actions/setup-java).
97100

98101
For reference, here is our complete [workflow example
99-
file](https://github.com/scalacenter/library-example/blob/master/.github/.workflows/ci.yml).
102+
file](https://github.com/scalacenter/library-example/blob/main/.github/workflows/ci.yml).
100103

101104
## Publish a Release
102105

@@ -309,10 +312,14 @@ jobs:
309312
release:
310313
runs-on: ubuntu-latest
311314
steps:
312-
- uses: actions/checkout@v2
315+
- uses: actions/checkout@v3
316+
with:
317+
fetch-depth: 0 # fetch all tags, required to compute the release version
318+
- uses: actions/setup-java@v3
313319
with:
314-
fetch-depth: 0 # fetch all tags, required for sbt-dynver
315-
- uses: olafurpg/setup-scala@v12
320+
distribution: temurin
321+
java-version: 8
322+
cache: sbt
316323
- run: sbt ci-release
317324
env:
318325
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
@@ -561,8 +568,14 @@ jobs:
561568
publishSite:
562569
runs-on: ubuntu-latest
563570
steps:
564-
- uses: actions/checkout@v2
565-
- uses: olafurpg/setup-scala@v12
571+
- uses: actions/checkout@v3
572+
with:
573+
fetch-depth: 0
574+
- uses: actions/setup-java@v3
575+
with:
576+
distribution: temurin
577+
java-version: 8
578+
cache: sbt
566579
- name: Generate site
567580
run: sbt makeSite
568581
- uses: JamesIves/github-pages-deploy-action@4.1.3
@@ -585,7 +598,7 @@ Add a `CONTRIBUTING.md` file to your repository, answering the following questio
585598
What are the coding practices to follow? Where are the tests and how to run them?
586599

587600
For reference, you can read our minimal example of
588-
[`CONTRIBUTING.md` file](https://github.com/scalacenter/library-example/blob/master/CONTRIBUTING.md).
601+
[`CONTRIBUTING.md` file](https://github.com/scalacenter/library-example/blob/main/CONTRIBUTING.md).
589602

590603
### Issue Labels
591604

0 commit comments

Comments
 (0)