forked from valkey-io/valkey-glide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Continuous Deployment workflow to publish to NPM
- Loading branch information
Showing
3 changed files
with
183 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
name: Continuous Deployment | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*.*" | ||
|
||
jobs: | ||
publish-npm-binaries: | ||
name: Publish NPM packages | ||
runs-on: ${{ matrix.build.RUNNER }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
build: | ||
- { | ||
OS: ubuntu-latest, | ||
NAMED_OS: linux, | ||
RUNNER: ubuntu-latest, | ||
ARCH: x64, | ||
TARGET: x86_64-unknown-linux-gnu, | ||
} | ||
- { | ||
OS: ubuntu-latest, | ||
NAMED_OS: linux, | ||
RUNNER: [self-hosted, Linux, ARM64], | ||
ARCH: arm64, | ||
TARGET: aarch64-unknown-linux-gnu, | ||
} | ||
- { | ||
OS: macos-latest, | ||
NAMED_OS: darwin, | ||
RUNNER: macos-latest, | ||
ARCH: x64, | ||
TARGET: x86_64-apple-darwin, | ||
} | ||
- { | ||
OS: macos-latest, | ||
NAMED_OS: darwin, | ||
RUNNER: macos-13-xlarge, | ||
arch: arm64, | ||
TARGET: aarch64-apple-darwin, | ||
} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: "true" | ||
|
||
- name: Set the release version | ||
shell: bash | ||
run: | | ||
echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV | ||
- name: Install Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
target: ${{ matrix.build.TARGET }} | ||
override: true | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16" | ||
registry-url: "https://registry.npmjs.org" | ||
architecture: ${{ matrix.build.ARCH }} | ||
scope: "${{ vars.NPM_SCOPE }}" | ||
always-auth: true | ||
token: ${{ secrets.NPM_AUTH_TOKEN }} | ||
|
||
- name: Build Node wrapper | ||
uses: ./.github/workflows/build-node-wrapper | ||
with: | ||
os: ${{ matrix.build.OS }} | ||
named_os: ${{ matrix.build.NAMED_OS }} | ||
arch: ${{ matrix.build.ARCH }} | ||
target: ${{ matrix.build.TARGET }} | ||
npm_scope: ${{ vars.NPM_SCOPE }} | ||
publish: "true" | ||
|
||
- name: Publish to NPM | ||
shell: bash | ||
working-directory: ./node | ||
run: | | ||
npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | ||
|
||
- name: Pack the package | ||
shell: bash | ||
working-directory: ./node | ||
run: | | ||
# Remove the "cpu" and "os" fileds so the base package would be able to install it on ubuntu | ||
SED_FOR_MACOS=`if [[ "${{ matrix.build.OS }}" =~ .*"macos".* ]]; then echo "''"; fi` | ||
sed -i $SED_FOR_MACOS '/"cpu":/d' ./package.json && sed -i $SED_FOR_MACOS '/"os":/d' ./package.json | ||
mkdir -p bin | ||
npm pack --pack-destination ./bin | ||
ls ./bin | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | ||
- name: Upload the package | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.build.TARGET }} | ||
path: ./node/bin | ||
if-no-files-found: error | ||
|
||
publish-npm-base: | ||
name: Publish the base NPM package | ||
needs: publish-npm-binaries | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: "true" | ||
|
||
- name: Install node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16" | ||
registry-url: "https://registry.npmjs.org" | ||
scope: "${{ vars.NPM_SCOPE }}" | ||
always-auth: true | ||
|
||
- name: Create package.json file | ||
shell: bash | ||
working-directory: ./node/npm/babushka | ||
run: | | ||
export pkg_name=babushka | ||
echo "${GITHUB_REF:11}" | ||
export package_version=${GITHUB_REF:11} | ||
export scope=`if [ "$NPM_SCOPE" != '' ]; then echo "$NPM_SCOPE/"; fi` | ||
envsubst < package.json.tmpl > "package.json" | ||
cat package.json | ||
# Fix index.ts based on the scope variable | ||
sed -i "s|@scope/|${scope}|g" index.ts | ||
env: | ||
NPM_SCOPE: ${{ vars.NPM_SCOPE }} | ||
|
||
- name: Create a directory for the packed packages | ||
shell: bash | ||
working-directory: ./node/npm/babushka | ||
run: mkdir packages | ||
|
||
- name: Download the packed packages | ||
id: download | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: ./node/npm/babushka/packages | ||
|
||
- name: Install the packed packages | ||
shell: bash | ||
working-directory: ./node/npm/babushka | ||
run: | | ||
ls -LR packages/ | ||
packages_list=`find ${{steps.download.outputs.download-path}} -type f -follow -print` | ||
for package in $packages_list | ||
do | ||
echo "Installing package $package" | ||
npm i --no-save "$package" | ||
done | ||
- name: Publish the base package | ||
shell: bash | ||
working-directory: ./node/npm/babushka | ||
run: | | ||
# Copy the main README file | ||
cp ../../README.md . | ||
npm install | ||
npm run build | ||
npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters