Skip to content

Adding support for node:alpine #255

Adding support for node:alpine

Adding support for node:alpine #255

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:
pull_request:
paths:
- .github/workflows/npm-cd.yml
- .github/workflows/build-node-wrapper/action.yml
- .github/workflows/start-self-hosted-runner/action.yml
push:
tags:
- "v*.*"
concurrency:
group: npm-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
start-self-hosted-runner:
if: github.repository_owner == 'aws'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Start self hosted EC2 runner
uses: ./.github/workflows/start-self-hosted-runner
with:
aws-access-key-id: ${{ secrets.AWS_EC2_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_EC2_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
ec2-instance-id: ${{ secrets.AWS_EC2_INSTANCE_ID }}
publish-binaries:
needs: start-self-hosted-runner
if: github.repository_owner == 'aws'
name: Publish packages to NPM
runs-on: ${{ matrix.build.RUNNER }}
strategy:
fail-fast: false
matrix:
build:
- {
OS: ubuntu,
NAMED_OS: linux,
RUNNER: ubuntu-latest,
ARCH: x64,
TARGET: x86_64-unknown-linux-gnu,
}
- {
OS: ubuntu,
NAMED_OS: linux,
RUNNER: [self-hosted, Linux, ARM64],
ARCH: arm64,
TARGET: aarch64-unknown-linux-gnu,
CONTAINER: "2_28",
}
- {
OS: macos,
NAMED_OS: darwin,
RUNNER: macos-12,
ARCH: x64,
TARGET: x86_64-apple-darwin,
}
- {
OS: macos,
NAMED_OS: darwin,
RUNNER: macos-13-xlarge,
arch: arm64,
TARGET: aarch64-apple-darwin,
}
steps:
- name: Setup self-hosted runner access
if: ${{ contains(matrix.build.RUNNER, 'self-hosted') }}
run: sudo chown -R $USER:$USER /home/ubuntu/actions-runner/_work/glide-for-redis
- name: Checkout
uses: actions/checkout@v4
with:
submodules: "true"
- name: Set the release version
shell: bash
run: |
export version=`if ${{ github.event_name == 'pull_request' }}; then echo '255.255.255'; else echo ${GITHUB_REF:11}; fi`
echo "RELEASE_VERSION=${version}" >> $GITHUB_ENV
- 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: Update package version in config.toml
uses: ./.github/workflows/update-glide-version
with:
folder_path: "${{ github.workspace }}/node/rust-client/.cargo"
named_os: ${{ matrix.build.NAMED_OS }}
- 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"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to NPM
if: github.event_name != 'pull_request'
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
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: github.event_name != 'pull_request'
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.build.TARGET }}
path: ./node/bin
if-no-files-found: error
set-up-gitconfig-for-cotntainer:
if: github.repository_owner == 'aws'
needs: start-self-hosted-runner
runs-on: [self-hosted, Linux, ARM64]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup self-hosted runner access
run: sudo chown -R $USER:$USER /home/ubuntu/actions-runner/_work/glide-for-redis
- name: Set up Git config for publish-musl-binaries
run: |
mkdir -p $HOME/musl-build-workspace
cp -r $GITHUB_WORKSPACE/* $HOME/musl-build-workspace
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
publish-musl-binaries:
needs: set-up-gitconfig-for-cotntainer
if: github.repository_owner == 'aws'
name: Publish packages to NPM
runs-on: ${{ matrix.build.RUNNER }}
container:
image: node:alpine
options: --user root
strategy:
fail-fast: false
matrix:
build:
- {
OS: ubuntu,
NAMED_OS: linux,
RUNNER: [self-hosted, Linux, ARM64],
ARCH: arm64,
TARGET: aarch64-unknown-linux-musl,
CONTAINER: "2_28",
}
- {
OS: ubuntu,
NAMED_OS: linux,
RUNNER: ubuntu-latest,
ARCH: x64,
TARGET: x86_64-unknown-linux-musl,
}
steps:
- name: Install dependencies
run: |
apk update
apk add bash envsubst git sed
# Currently it is not possible to use the checkout action with self-hosted runners on alpine so we need to do it manually
- name: Checkout repository for ARM64
if: ${{ contains(matrix.build.RUNNER, 'self-hosted') }}
shell: bash
run: |
git config --global safe.directory "$HOME/musl-build-workspace"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout repository for x64
if: ${{ !contains(matrix.build.RUNNER, 'self-hosted') }}
uses: actions/checkout@v4
with:
submodules: "true"
- name: Set the release version
shell: bash
run: |
export version=`if ${{ github.event_name == 'pull_request' }}; then echo '255.255.255'; else echo ${GITHUB_REF:11}; fi`
echo "RELEASE_VERSION=${version}" >> $GITHUB_ENV
- name: Set the package name
shell: bash
run: |
export pkg_name=`if [ "${{ matrix.build.ARCH }}" == 'x64' ]; then echo "glide-for-redis-linux-musl-x64"; else echo "glide-for-redis-linux-musl-arm64"; fi`
echo "PKG_NAME=${pkg_name}" >> $GITHUB_ENV
- name: Update package version in config.toml
uses: ./.github/workflows/update-glide-version
with:
folder_path: "${{ github.workspace }}/node/rust-client/.cargo"
named_os: ${{ matrix.build.NAMED_OS }}
- 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"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup node
working-directory: ./node
run: |
npm config set registry https://registry.npmjs.org/
npm config set '//registry.npmjs.org/:_authToken' ${{ secrets.NPM_AUTH_TOKEN }}
npm config set scope ${{ vars.NPM_SCOPE }}
- name: Publish to NPM
if: github.event_name != 'pull_request'
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
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 -i '/"\/\/\/cpu": \[/,/]/d' ./package.json && sed -i '/"\/\/\/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: github.event_name != 'pull_request'
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.build.TARGET }}
path: ./node/bin
if-no-files-found: error
publish-base-to-npm:
if: github.event_name != 'pull_request'
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
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
if: github.event_name != 'pull_request'
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 }}