Skip to content

Configure concurrency for all CI. (#106) #37

Configure concurrency for all CI. (#106)

Configure concurrency for all CI. (#106) #37

Workflow file for this run

# The cross platform build was created based on the [Packaging Rust Applications for the NPM Registry blog](https://blog.orhun.dev/packaging-rust-for-npm/).
name: Continuous Deployment
on:
push:
tags:
- "v*.*"
concurrency:
group: npm-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
publish-binaries:
name: Publish packages to NPM
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,
NPM_PUBLISH: true,
}
- {
OS: ubuntu-latest,
NAMED_OS: linux,
RUNNER: [self-hosted, Linux, ARM64],
ARCH: arm64,
TARGET: aarch64-unknown-linux-gnu,
NPM_PUBLISH: true,
CONTAINER: "2_28",
}
- {
OS: macos-latest,
NAMED_OS: darwin,
RUNNER: macos-latest,
ARCH: x64,
TARGET: x86_64-apple-darwin,
NPM_PUBLISH: true,
}
- {
OS: macos-latest,
NAMED_OS: darwin,
RUNNER: macos-13-xlarge,
arch: arm64,
TARGET: aarch64-apple-darwin,
NPM_PUBLISH: true,
}
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: Setup node
if: matrix.build.NPM_PUBLISH == true
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
if: matrix.build.NPM_PUBLISH == true
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"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to NPM
if: matrix.build.NPM_PUBLISH == true
shell: bash
working-directory: ./node
run: |
set +e
# Redirect only stderr
{ npm_publish_err=$(npm publish --access public 2>&1 >&3 3>&-); } 3>&1
if [[ "$npm_publish_err" == *"You cannot publish over the previously published versions"* ]]
then
echo "Skipping publishing, package already published"
elif [[ ! -z "$npm_publish_err" ]]
then
echo "Failed to publish with error: ${npm_publish_err}"
exit 1
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Pack the Node package
if: matrix.build.NPM_PUBLISH == true
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 Node package
if: matrix.build.NPM_PUBLISH == true
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.build.TARGET }}
path: ./node/bin
if-no-files-found: error
publish-base-to-npm:
name: Publish the base NPM package
needs: publish-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/glide
run: |
export pkg_name=glide-for-redis
echo "${GITHUB_REF:11}"
export package_version=${GITHUB_REF:11}
export scope=`if [ "$NPM_SCOPE" != '' ]; then echo "$NPM_SCOPE/"; fi`
mv package.json package.json.tmpl
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: Build Node wrapper
uses: ./.github/workflows/build-node-wrapper
with:
os: ubuntu-latest
target: "x86_64-unknown-linux-gnu"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a directory for the packed packages
shell: bash
working-directory: ./node/npm/glide
run: mkdir packages
- name: Download the packed packages
id: download
uses: actions/download-artifact@v3
with:
path: ./node/npm/glide/packages
- name: Install the packed packages
shell: bash
working-directory: ./node/npm/glide
run: |
ls -LR packages/
packages_list=`find ${{steps.download.outputs.download-path}} -type f -follow -print`
for package in $packages_list
do
if [[ "${package}" == *.tgz ]]
then
echo "Installing package $package"
npm i --no-save "$package"
fi
done
- name: Publish the base package
shell: bash
working-directory: ./node/npm/glide
run: |
# Copy the main README file
cp ../../README.md .
npm install
npm run build
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}