diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..99fc380c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,79 @@ +name: GitHub Release + +on: + push: + tags: ['v*'] + +permissions: + contents: read + +concurrency: + group: release-${{ github.ref }} + +jobs: + package: + runs-on: ubuntu-slim + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version: 22.x + cache: npm + - name: Check tag and package version + run: | + version=$(node -p 'require("./package.json").version') + if [[ "$GITHUB_REF_NAME" != "v$version" ]]; then + echo "Tag $GITHUB_REF_NAME must match package version v$version" >&2 + exit 1 + fi + - run: npm ci + - run: npm test + - run: npm pack + - name: Test the packaged CLI + run: | + prefix=$(mktemp -d) + npm install --global --prefix "$prefix" "./javascripting-${GITHUB_REF_NAME#v}.tgz" + cd "$prefix" + HOME="$prefix" LANG=en ./bin/javascripting --help + HOME="$prefix" LANG=en ./bin/javascripting select 0 + HOME="$prefix" LANG=en ./bin/javascripting current | grep -F INTRODUCTION + - uses: actions/upload-artifact@v4 + with: + name: npm-package + path: javascripting-*.tgz + if-no-files-found: error + + publish: + needs: package + runs-on: ubuntu-slim + permissions: + contents: write + steps: + - uses: actions/setup-node@v7 + with: + node-version: 22.x + - uses: actions/download-artifact@v4 + with: + name: npm-package + - name: Publish and verify the release + env: + GH_TOKEN: ${{ github.token }} + run: | + package="javascripting-${GITHUB_REF_NAME#v}.tgz" + url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/$GITHUB_REF_NAME/$package" + cat > "$RUNNER_TEMP/release-notes.md" </dev/null; then + gh release create "$GITHUB_REF_NAME" "$package" --repo "$GITHUB_REPOSITORY" \ + --verify-tag --generate-notes --notes-file "$RUNNER_TEMP/release-notes.md" + fi + prefix=$(mktemp -d) + npm install --global --prefix "$prefix" "$url" + cd "$prefix" + HOME="$prefix" LANG=en ./bin/javascripting --help diff --git a/README.md b/README.md index 0a429572..6a30eecb 100644 --- a/README.md +++ b/README.md @@ -13,15 +13,13 @@ Also, take a look into our [troubleshooting documentation](https://github.com/wo 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. -### Install `javascripting` with `npm` +### Install from GitHub Releases -Open your terminal and run this command: +Use the version-specific install command in the [GitHub release notes](https://github.com/workshopper/javascripting/releases). For version 3.0.0, run +```sh +npm install -g https://github.com/workshopper/javascripting/releases/download/v3.0.0/javascripting-3.0.0.tgz ``` -npm install -g javascripting -``` - -The `-g` option installs this module globally so that you can run it as a command in your terminal. ## Run the workshop diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md index bdc042e2..ae3745f4 100644 --- a/TROUBLESHOOTING.md +++ b/TROUBLESHOOTING.md @@ -2,21 +2,11 @@ ### `EACCES` during installation -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: +If the GitHub Release install command fails with `EACCES`, your account may lack write access to npm’s global installation directory. -```sh -npx javascripting -``` +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/). -When an exercise asks you to run a workshop command, prefix it with `npx`, for example `npx javascripting verify introduction.js`. - -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/). - -After completing the setup, retry the installation from your regular terminal: - -```sh -npm install -g javascripting -``` +After completing the setup, retry the [GitHub Release install command](README.md#install-from-github-releases) from your regular terminal. ### `EEXIST` error diff --git a/package-lock.json b/package-lock.json index 7737dcb9..b8c2b64a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "javascripting", - "version": "2.7.4", + "version": "3.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "javascripting", - "version": "2.7.4", + "version": "3.0.0", "license": "MIT", "dependencies": { "colors": "1.4.0", diff --git a/package.json b/package.json index d179b3d9..e2aba2b4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "javascripting", "description": "Learn JavaScript by adventuring around in the terminal.", - "version": "2.7.4", + "version": "3.0.0", "author": "sethvincent", "bin": { "javascripting": "./bin/javascripting"