-
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.
- Loading branch information
Showing
6 changed files
with
242 additions
and
29 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
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,29 @@ | ||
name: Build builder for napi crates | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: napi | ||
|
||
jobs: | ||
build-rust-test-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 'Checkout' | ||
uses: actions/checkout@v3 | ||
- name: Login to ACR | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
# Build and Push Image with Cache | ||
- name: Build & Push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: docker/napi_builder | ||
push: true | ||
tags: | | ||
ghcr.io/foresightminingsoftwarecorporation/napi-rs-docker-builder:latest |
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,136 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
working-directory: | ||
type: string | ||
default: "" | ||
|
||
jobs: | ||
check_release_npm: | ||
name: Check NPM Packages | ||
runs-on: "ubuntu-latest" | ||
outputs: | ||
name: ${{ steps.read_package_json.outputs.name }} | ||
current-version: ${{ steps.read_package_json.outputs.current-version }} | ||
exists: ${{ steps.check-version-exists.outputs.exists }} | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get version in package.json | ||
id: read_package_json | ||
run: | | ||
echo "name=$(cat package.json | jq -r '.name' | rev | cut -d'/' -f 1 | rev)" >> $GITHUB_OUTPUT | ||
echo "current-version=$(cat package.json | jq -r '.version')" >> $GITHUB_OUTPUT | ||
working-directory: ${{ inputs.working-directory }} | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
check-latest: true | ||
registry-url: https://npm.pkg.github.com/ | ||
scope: "@foresightminingsoftwarecorporation" | ||
|
||
- name: Check if package with same version exists | ||
id: check-version-exists | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.GH_REGISTRY_PACKAGES }} | ||
run: | | ||
if npm view @foresightminingsoftwarecorporation/${{ steps.read_package_json.outputs.name }} --json > package_info.json ; then | ||
EXISTS=$(cat package_info.json | jq '.time | has("${{ steps.read_package_json.outputs.current-version }}")') | ||
else | ||
EXISTS="false" | ||
fi | ||
echo "exists=$EXISTS" >> $GITHUB_OUTPUT | ||
working-directory: ${{ inputs.working-directory }} | ||
|
||
build_artifacts_rust: | ||
name: Build napi artifacts | ||
needs: | ||
- check_release_npm | ||
if: ${{ needs.check_release_npm.outputs.exists == 'false' }} | ||
strategy: | ||
matrix: | ||
os: | ||
- name: ubuntu-latest | ||
arch: x86_64-unknown-linux-gnu | ||
ext: '' | ||
- name: windows-latest | ||
arch: x86_64-pc-windows-msvc | ||
ext: .exe | ||
runs-on: ${{ matrix.os.name }} | ||
|
||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v4 | ||
|
||
- uses: ForesightMiningSoftwareCorporation/github/.github/actions/login-private-registry@v1 | ||
with: | ||
private_key: ${{ secrets.CARGO_PRIVATE_REGISTRY_SSH_PRIVATE_KEY }} | ||
host: ${{ secrets.CARGO_PRIVATE_REGISTRY_HOST }} | ||
name: ${{ secrets.CARGO_PRIVATE_REGISTRY_NAME }} | ||
token: ${{ secrets.CARGO_PRIVATE_REGISTRY_TOKEN }} | ||
additional_private_keys: | | ||
${{ secrets.FSE_SSH_PRIVATE_KEY }} | ||
${{ secrets.BEVY_CLIPMAP_SSH_PRIVATE_KEY }} | ||
${{ secrets.DAG_TABLES_SSH_PRIVATE_KEY }} | ||
${{ secrets.VOLUMESIGHT_SSH_PRIVATE_KEY }} | ||
- name: Build rust package | ||
uses: ForesightMiningSoftwareCorporation/github/.github/actions/build-napi-artifact@napi | ||
with: | ||
runner_os: ${{ matrix.os.name }} | ||
runner_arch: ${{ matrix.os.arch }} | ||
runner_extension: ${{ matrix.os.ext }} | ||
docker: ghcr.io/foresightminingsoftwarecorporation/napi-rs-docker-builder:latest | ||
docker_build: ls -ahl ~/.ssh && yarn install && yarn build --target x86_64-unknown-linux-musl --js=false | ||
node_auth_token: ${{ secrets.GITHUB_TOKEN }} | ||
npm_token: ${{ secrets.GH_REGISTRY_PACKAGES }} | ||
shipyard_token: ${{ secrets.CARGO_PRIVATE_REGISTRY_TOKEN }} | ||
working-directory: ${{ inputs.working-directory }} | ||
bin: ${{ needs.check_release_npm.outputs.name }} | ||
|
||
create_release_npm: | ||
name: Publish NPM Packages | ||
runs-on: "ubuntu-latest" | ||
needs: | ||
- check_release_npm | ||
- build_artifacts_rust | ||
steps: | ||
- name: Install dependencies | ||
if: ${{ needs.check_release_npm.outputs.exists == 'false' }} | ||
run: yarn install | ||
working-directory: ${{ inputs.working-directory }} | ||
|
||
- name: Download all artifacts | ||
if: ${{ needs.check_release_npm.outputs.exists == 'false' }} | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: ${{ inputs.working-directory }}/raw_artifacts | ||
|
||
- name: Move Artifacts and rename | ||
if: ${{ needs.check_release_npm.outputs.exists == 'false' }} | ||
shell: bash | ||
run: |- | ||
mkdir -p artifacts | ||
for f in raw_artifacts/bindings-${{ needs.check_release_npm.outputs.name }}-*; do | ||
NEW_NAME="${f/-${{ needs.check_release_npm.outputs.name }}/}" | ||
mv -- "$f" "${NEW_NAME/raw_artifacts/artifacts}" | ||
done | ||
working-directory: ${{ inputs.working-directory }} | ||
|
||
- name: Move artifacts | ||
if: ${{ needs.check_release_npm.outputs.exists == 'false' }} | ||
run: yarn artifacts | ||
working-directory: ${{ inputs.working-directory }} | ||
|
||
- name: Publish | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.GH_REGISTRY_PACKAGES }} | ||
if: ${{ false && needs.check_release_npm.outputs.exists == 'false' }} | ||
run: | | ||
npm publish | ||
working-directory: ${{ inputs.working-directory }} |
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,33 @@ | ||
FROM rust:alpine | ||
|
||
ENV PATH="/aarch64-linux-musl-cross/bin:/usr/local/cargo/bin/rustup:/root/.cargo/bin:$PATH" \ | ||
RUSTFLAGS="-C target-feature=-crt-static" \ | ||
CC="clang" \ | ||
CXX="clang++" \ | ||
GN_EXE=gn | ||
|
||
RUN apk add --update --no-cache nodejs yarn bash clang wget cmake git openssh make perl pkgconfig openssl-dev curl gcc musl-dev linux-headers | ||
|
||
|
||
WORKDIR /tmp | ||
|
||
RUN curl -fLO "https://www.openssl.org/source/openssl-1.1.1m.tar.gz" | ||
RUN tar xvzf "openssl-1.1.1m.tar.gz" | ||
WORKDIR /tmp/openssl-1.1.1m | ||
RUN ./config -fPIC | ||
RUN make -j$(nproc) depend | ||
RUN make -j$(nproc) | ||
RUN make -j$(nproc) install_sw | ||
|
||
ENV OPENSSL_LIB_DIR=/usr/local/lib | ||
ENV OPENSSL_INCLUDE_DIR=/usr/include/openssl | ||
ENV OPENSSL_STATIC=yes | ||
|
||
WORKDIR /build | ||
|
||
RUN mkdir /ssh | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
RUN chmod +x /entrypoint.sh | ||
|
||
ENTRYPOINT /entrypoint.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,10 @@ | ||
#!/bin/sh | ||
|
||
chown root:root ~/.gitconfig | ||
chown -R root:root ~/.ssh | ||
|
||
sed 's|/home/runner|/root|g' -i.bak ~/.ssh/config | ||
chmod -R 600 ~/.ssh | ||
|
||
# This will exec the CMD from your Dockerfile, i.e. "npm start" | ||
exec "sh -c \"$@\"" |