From 6c3d9d61a80fe788fea483c45b6e4eeea2384639 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sat, 25 Jun 2022 20:22:12 +0200 Subject: [PATCH] add npm package --- action.yml | 16 ++-------------- package.json | 13 +++++++++++++ scripts/hyperlink-bin | 4 ++++ scripts/install.sh | 21 +++++++++++++++++++++ scripts/release-version.sh | 3 +++ 5 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 package.json create mode 100755 scripts/hyperlink-bin create mode 100755 scripts/install.sh diff --git a/action.yml b/action.yml index 51ce26f..8e10ccf 100644 --- a/action.yml +++ b/action.yml @@ -15,21 +15,9 @@ runs: run: | set -x cd ${{ github.action_path }} - tag="$(grep '^version = ' Cargo.toml | head -1 | cut -d '"' -f2)" - - if [ "$RUNNER_OS" == "Linux" ]; then - curl -L -o bin https://github.com/untitaker/hyperlink/releases/download/$tag/hyperlink-linux-x86_64 - elif [ "$RUNNER_OS" == "Windows" ]; then - curl -L -o bin https://github.com/untitaker/hyperlink/releases/download/$tag/hyperlink-windows-x86_64.exe - elif [ "$RUNNER_OS" = "MacOS" ]; then - curl - L -o bin https://github.com/untitaker/hyperlink/releases/download/$tag/hyperlink-mac-x86_64 - else - echo "$RUNNER_OS not supported" - exit 1 - fi - chmod +x bin + sh scripts/install.sh shell: bash - name: Run Hyperlink - run: ${{ github.action_path }}/bin ${{ inputs.args }} --github-actions + run: ${{ github.action_path }}/hyperlink ${{ inputs.args }} --github-actions shell: bash diff --git a/package.json b/package.json new file mode 100644 index 0000000..ed3d14d --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "name": "@untitaker/hyperlink", + "description": "Very fast link checker for CI.", + "license": "MIT", + "version": "0.1.22", + "bin": { + "hyperlink": "scripts/hyperlink-bin" + }, + "scripts": { + "install": "scripts/install.sh" + }, + "files": ["scripts/install.sh", "scripts/hyperlink-bin"] +} diff --git a/scripts/hyperlink-bin b/scripts/hyperlink-bin new file mode 100755 index 0000000..d465e49 --- /dev/null +++ b/scripts/hyperlink-bin @@ -0,0 +1,4 @@ +#!/bin/sh +# install.sh is supposed to overwrite this file during installation +echo "npm/yarn did not run postinstall script correctly. please run script/install.sh manually." +exit 1 diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 0000000..f5ac64d --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,21 @@ +#!/bin/sh +UNAME=$(uname) +tag="$(grep '"version":' ./package.json | cut -d'"' -f4)" +echo "downloading hyperlink $tag for $UNAME" +case $UNAME in + Linux) ( + curl -L -o scripts/hyperlink-bin https://github.com/untitaker/hyperlink/releases/download/$tag/hyperlink-linux-x86_64 + ) ;; + Darwin) ( + curl -L -o scripts/hyperlink-bin https://github.com/untitaker/hyperlink/releases/download/$tag/hyperlink-mac-x86_64 + ) ;; + CYGWIN*) ( + curl -L -o scripts/hyperlink-bin https://github.com/untitaker/hyperlink/releases/download/$tag/hyperlink-windows-x86_64.exe + ) ;; + *) ( + echo "$UNAME not supported" + exit 1 + ) +esac + +chmod +x scripts/hyperlink-bin diff --git a/scripts/release-version.sh b/scripts/release-version.sh index 10b3812..30c4f4b 100644 --- a/scripts/release-version.sh +++ b/scripts/release-version.sh @@ -18,6 +18,8 @@ sed -i.bak "s/$action_prefix$current_version/$action_prefix$new_version/" README rm README.md.bak sed -i.bak "s/version = \"$current_version\"/version = \"$new_version\"/" Cargo.toml rm Cargo.toml.bak +sed -i.bak "s/\"version\": \"$current_version\"/\"version\": \"$new_version\"/" package.json +rm package.json.bak echo ">>> Running tests" cargo build @@ -36,6 +38,7 @@ set +x echo "things left to do:" echo " cargo publish" +echo " npm publish" echo " git push" echo " git push origin $new_version" echo " uncheck and check 'Publish to Marketplace' property of the new release"