Skip to content

Commit

Permalink
feat(cli, ci): Introduce build steps and -v command
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidHancu committed Feb 27, 2023
0 parents commit aee9ecc
Show file tree
Hide file tree
Showing 23 changed files with 1,820 additions and 0 deletions.
161 changes: 161 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: "Deploy Turboprisma"

on:
release:
types: [published]

jobs:
build:
name: "Build targets"
strategy:
matrix:
target: [aarch64-unknown-linux-gnu, x86_64-unknown-linux-gnu, aarch64-pc-windows-msvc, x86_64-pc-windows-msvc, aarch64-apple-darwin, x86_64-apple-darwin]
include:
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
package: "@turboprisma/cli-linux-arm64"
output: ""
npm_os: "linux"
npm_cpu: "arm"
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
package: "@turboprisma/cli-linux-x64"
output: ""
npm_os: "linux"
npm_cpu: "x64"
- target: aarch64-pc-windows-msvc
os: windows-latest
package: "@turboprisma/cli-windows-arm64"
output: ".exe"
npm_os: "win32"
npm_cpu: "arm"
- target: x86_64-pc-windows-msvc
os: windows-latest
package: "@turboprisma/cli-windows-x64"
output: ".exe"
npm_os: "win32"
npm_cpu: "x64"
- target: aarch64-apple-darwin
os: macos-latest
package: "@turboprisma/cli-darwin-arm64"
output: ""
npm_os: "darwin"
npm_cpu: "arm"
- target: x86_64-apple-darwin
os: macos-latest
package: "@turboprisma/cli-darwin-x64"
output: ""
npm_os: "darwin"
npm_cpu: "x64"

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true

#- name: "Build turboprisma_ast ${{ matrix.target }}"
# uses: actions-rs/cargo@v1
# with:
# use-cross: true
# command: build
# args: --package turboprisma_ast --release --target ${{ matrix.target }}

- name: "Build turboprisma_cli ${{ matrix.target }}"
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --package turboprisma_cli --release --target ${{ matrix.target }}

- name: Create CLI binary package folder
run: mkdir npm-release-root

- name: Copy turboprisma_cli${{ matrix.output }} to binary package folder
uses: chpoit/js-copy-github-action@master
with:
source: "target/${{ matrix.target }}/release/turboprisma_cli${{ matrix.output }}"
target: "npm-release-root/turboprisma_cli${{ matrix.output }}"

- name: Copy LICENSE to CLI binary package folder
uses: chpoit/js-copy-github-action@master
with:
source: "LICENSE"
target: "npm-release-root/LICENSE"

- name: Copy README to CLI binary package folder
uses: chpoit/js-copy-github-action@master
with:
source: "assets/README.md"
target: "npm-release-root/README.md"

- name: Read CLI package.json
id: cli
uses: juliangruber/read-file-action@v1
with:
path: ./packages/turboprisma/package.json

- name: Dump CLI package.json version
run: echo '${{ fromJSON(steps.cli.outputs.content).version }}'

- name: Fill CLI package.json template
uses: bluwy/substitute-string-action@v1
id: sub
with:
_input-file: ./assets/package.json
RINSERT_NAMER: ${{ matrix.package }}
RINSERT_VERSIONR: ${{ fromJSON(steps.cli.outputs.content).version }}
RINSERT_OSR: ${{ matrix.npm_os }}
RINSERT_CPUR: ${{ matrix.npm_cpu }}

- name: Dump template package.json
run: echo '${{ steps.sub.outputs.result }}'

- name: Write template package.json to CLI binary package folder
uses: DamianReeves/write-file-action@master
with:
path: npm-release-root/package.json
contents: ${{ steps.sub.outputs.result }}
write-mode: append

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'

- name: Publish CLI binary to NPM
run: |
cd npm-release-root
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
#- name: "Acquire wasm-pack"
# uses: jetli/[email protected]
# with:
# version: 'latest'

#- name: "Build turboprisma_ast_wasm ${{ matrix.target }}"
# run: wasm-pack build crates/ast/turboprisma_ast_wasm --out-name index --release --target nodejs

publish_npm_cli:
name: "Publish turboprisma"
runs-on: ubuntu-latest
needs: build

steps:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- name: Publish
run: |
cd packages/turboprisma
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/target
node_modules

# not ready yet
/crates/ast
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
auto-install-peers = true
hoist = false
Loading

0 comments on commit aee9ecc

Please sign in to comment.