-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Distribute
cerbos
and cerbosctl
via npm
Signed-off-by: Andrew Haines <haines@cerbos.dev>
- Loading branch information
Showing
73 changed files
with
4,022 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,19 @@ | ||
name: Publish npm packages | ||
|
||
description: Publish npm packages (assuming binaries have already been copied into the correct locations) | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: .node-version | ||
|
||
- name: Publish npm packages | ||
shell: bash | ||
working-directory: npm | ||
run: corepack npm publish --workspaces --access=public --provenance | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Publish npm packages from an existing GitHub release | ||
on: workflow_dispatch | ||
jobs: | ||
publish-npm-packages: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download binaries | ||
run: hack/scripts/download-released-binaries-to-npm-packages.sh | ||
|
||
- name: Publish npm packages | ||
uses: ./.github/actions/publish-npm-packages |
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
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
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 @@ | ||
20.11.1 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ go 1.22 | |
use ( | ||
. | ||
./api/genpb | ||
./hack/tools/generate-npm-packages | ||
./hack/tools/testsplit | ||
./tools | ||
) |
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,23 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright 2021-2024 Zenauth Ltd. | ||
|
||
set -euo pipefail | ||
|
||
project_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../" && pwd)" | ||
|
||
if [[ "${BINARY_ARCH}" = "amd64" ]]; then | ||
BINARY_ARCH="x64" | ||
fi | ||
|
||
package_name="${BINARY_NAME}-${BINARY_OS}-${BINARY_ARCH}" | ||
package_dir="${project_dir}/npm/packages/${package_name}" | ||
|
||
package_version=$(jq --raw-output .version < "${package_dir}/package.json") | ||
|
||
if [[ "${package_version}" != "${BINARY_VERSION}" ]]; then | ||
printf "The binary version (%s) does not match the npm package version (%s)\n" "${BINARY_VERSION}" "${package_version}" >&2 | ||
exit 1 | ||
fi | ||
|
||
cp "${BINARY_PATH}" "${package_dir}/${package_name}" |
70 changes: 70 additions & 0 deletions
70
hack/scripts/download-released-binaries-to-npm-packages.sh
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,70 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright 2021-2024 Zenauth Ltd. | ||
|
||
set -euo pipefail | ||
|
||
download_artifact() { | ||
local filename="$1" | ||
curl --fail --silent --show-error --location --output "${filename}" "https://github.com/cerbos/cerbos/releases/download/v${version}/${filename}" | ||
} | ||
|
||
extract_binary() { | ||
local archive="$1" | ||
local binary="${archive%%_*}" | ||
|
||
local os | ||
case "${archive}" in | ||
*Darwin*) | ||
os=darwin | ||
;; | ||
|
||
*Linux*) | ||
os=linux | ||
;; | ||
esac | ||
|
||
local arch | ||
case "${archive}" in | ||
*arm64*) | ||
arch=arm64 | ||
;; | ||
|
||
*x86_64*) | ||
arch=x64 | ||
;; | ||
esac | ||
|
||
tar --extract --file "${archive}" "${binary}" | ||
mv "${binary}" "${project_dir}/npm/packages/${binary}-${os}-${arch}/${binary}-${os}-${arch}" | ||
} | ||
|
||
project_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../" && pwd)" | ||
|
||
version=$(jq --raw-output .version < "${project_dir}/npm/packages/cerbos/package.json") | ||
|
||
tmp_dir=$(mktemp -d) | ||
trap "rm -rf ${tmp_dir}" EXIT | ||
cd "${tmp_dir}" | ||
|
||
archives=( | ||
"cerbos_${version}_Darwin_arm64.tar.gz" | ||
"cerbos_${version}_Darwin_x86_64.tar.gz" | ||
"cerbos_${version}_Linux_arm64.tar.gz" | ||
"cerbos_${version}_Linux_x86_64.tar.gz" | ||
"cerbosctl_${version}_Darwin_arm64.tar.gz" | ||
"cerbosctl_${version}_Darwin_x86_64.tar.gz" | ||
"cerbosctl_${version}_Linux_arm64.tar.gz" | ||
"cerbosctl_${version}_Linux_x86_64.tar.gz" | ||
) | ||
|
||
for archive in "${archives[@]}"; do | ||
download_artifact "${archive}" | ||
done | ||
|
||
download_artifact checksums.txt | ||
sha256sum --check --ignore-missing --quiet checksums.txt | ||
|
||
for archive in "${archives[@]}"; do | ||
extract_binary "${archive}" | ||
done |
Oops, something went wrong.