Skip to content

Commit c79869b

Browse files
authored
Merge pull request #388 from workshopper/release/github-actions-v3
Automate GitHub Releases for javascripting v3
2 parents 3b0354a + c0d725d commit c79869b

5 files changed

Lines changed: 89 additions & 22 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: GitHub Release
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
7+
permissions:
8+
contents: read
9+
10+
concurrency:
11+
group: release-${{ github.ref }}
12+
13+
jobs:
14+
package:
15+
runs-on: ubuntu-slim
16+
steps:
17+
- uses: actions/checkout@v7
18+
- uses: actions/setup-node@v7
19+
with:
20+
node-version: 22.x
21+
cache: npm
22+
- name: Check tag and package version
23+
run: |
24+
version=$(node -p 'require("./package.json").version')
25+
if [[ "$GITHUB_REF_NAME" != "v$version" ]]; then
26+
echo "Tag $GITHUB_REF_NAME must match package version v$version" >&2
27+
exit 1
28+
fi
29+
- run: npm ci
30+
- run: npm test
31+
- run: npm pack
32+
- name: Test the packaged CLI
33+
run: |
34+
prefix=$(mktemp -d)
35+
npm install --global --prefix "$prefix" "./javascripting-${GITHUB_REF_NAME#v}.tgz"
36+
cd "$prefix"
37+
HOME="$prefix" LANG=en ./bin/javascripting --help
38+
HOME="$prefix" LANG=en ./bin/javascripting select 0
39+
HOME="$prefix" LANG=en ./bin/javascripting current | grep -F INTRODUCTION
40+
- uses: actions/upload-artifact@v4
41+
with:
42+
name: npm-package
43+
path: javascripting-*.tgz
44+
if-no-files-found: error
45+
46+
publish:
47+
needs: package
48+
runs-on: ubuntu-slim
49+
permissions:
50+
contents: write
51+
steps:
52+
- uses: actions/setup-node@v7
53+
with:
54+
node-version: 22.x
55+
- uses: actions/download-artifact@v4
56+
with:
57+
name: npm-package
58+
- name: Publish and verify the release
59+
env:
60+
GH_TOKEN: ${{ github.token }}
61+
run: |
62+
package="javascripting-${GITHUB_REF_NAME#v}.tgz"
63+
url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/$GITHUB_REF_NAME/$package"
64+
cat > "$RUNNER_TEMP/release-notes.md" <<NOTES
65+
Requires Node.js 22.12.0 or later.
66+
67+
\`\`\`sh
68+
npm install -g $url
69+
javascripting
70+
\`\`\`
71+
NOTES
72+
if ! gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null; then
73+
gh release create "$GITHUB_REF_NAME" "$package" --repo "$GITHUB_REPOSITORY" \
74+
--verify-tag --generate-notes --notes-file "$RUNNER_TEMP/release-notes.md"
75+
fi
76+
prefix=$(mktemp -d)
77+
npm install --global --prefix "$prefix" "$url"
78+
cd "$prefix"
79+
HOME="$prefix" LANG=en ./bin/javascripting --help

‎README.md‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ Also, take a look into our [troubleshooting documentation](https://github.com/wo
1313

1414
Install a [Node.js LTS release](https://nodejs.org/en/download). The minimum supported version is Node.js 22.12.0. We use the oldest [LTS release line still supported by Node.js](https://github.com/nodejs/Release#release-schedule) as the minimum.
1515

16-
### Install `javascripting` with `npm`
16+
### Install from GitHub Releases
1717

18-
Open your terminal and run this command:
18+
Use the version-specific install command in the [GitHub release notes](https://github.com/workshopper/javascripting/releases). For version 3.0.0, run
1919

20+
```sh
21+
npm install -g https://github.com/workshopper/javascripting/releases/download/v3.0.0/javascripting-3.0.0.tgz
2022
```
21-
npm install -g javascripting
22-
```
23-
24-
The `-g` option installs this module globally so that you can run it as a command in your terminal.
2523

2624
## Run the workshop
2725

‎TROUBLESHOOTING.md‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,11 @@
22

33
### `EACCES` during installation
44

5-
If `npm install -g javascripting` fails with `EACCES`, your account may lack write access to npm’s global installation directory. You can start the workshop directly:
5+
If the GitHub Release install command fails with `EACCES`, your account may lack write access to npm’s global installation directory.
66

7-
```sh
8-
npx javascripting
9-
```
7+
npm recommends installing Node.js and npm with a Node version manager. On macOS and Linux, you can also configure npm to install global packages in your home directory. Follow [npm’s guide to resolving global installation permissions](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally/).
108

11-
When an exercise asks you to run a workshop command, prefix it with `npx`, for example `npx javascripting verify introduction.js`.
12-
13-
If you prefer a global installation, npm recommends installing Node.js and npm with a Node version manager. On macOS and Linux, you can also configure npm to install global packages in your home directory. Follow [npm’s guide to resolving global installation permissions](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally/).
14-
15-
After completing the setup, retry the installation from your regular terminal:
16-
17-
```sh
18-
npm install -g javascripting
19-
```
9+
After completing the setup, retry the [GitHub Release install command](README.md#install-from-github-releases) from your regular terminal.
2010

2111
### `EEXIST` error
2212

‎package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "javascripting",
33
"description": "Learn JavaScript by adventuring around in the terminal.",
4-
"version": "2.7.4",
4+
"version": "3.0.0",
55
"author": "sethvincent",
66
"bin": {
77
"javascripting": "./bin/javascripting"

0 commit comments

Comments
 (0)