Skip to content

Commit

Permalink
Merge pull request #186 from depot/packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie authored Sep 15, 2023
2 parents 12d1753 + 2bc713b commit a71546e
Show file tree
Hide file tree
Showing 32 changed files with 2,554 additions and 2 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ jobs:
go-version: "1.20.5"
check-latest: true
cache: true

- name: Install pnpm
uses: pnpm/[email protected]
with:
version: 8.x.x

- name: Install Node 18
uses: actions/setup-node@v3
with:
node-version: "18"
cache: pnpm
cache-dependency-path: npm/pnpm-lock.yaml

- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
working-directory: npm

- name: Verify dependencies
run: |
go mod verify
Expand Down Expand Up @@ -44,6 +61,12 @@ jobs:
args: --timeout 5m
github-token: ${{ secrets.GITHUB_TOKEN }}

- run: pnpm fmt:check
working-directory: npm

- run: pnpm type-check
working-directory: npm

build:
runs-on: ubuntu-latest-16-cores
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
Expand All @@ -54,11 +77,32 @@ jobs:
go-version: "1.20.5"
check-latest: true
cache: true

- name: Install pnpm
uses: pnpm/[email protected]
with:
version: 8.x.x

- name: Install Node 18
uses: actions/setup-node@v3
with:
node-version: "18"
cache: pnpm
cache-dependency-path: npm/pnpm-lock.yaml

- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
working-directory: npm

- uses: goreleaser/goreleaser-action@v4
with:
version: 1.19.0
args: build --clean --snapshot

- run: make npm
env:
DEPOT_CLI_VERSION: v0.0.0-dev

package:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,49 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'dev-')
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: "1.20.5"
check-latest: true
cache: true

- name: Install pnpm
uses: pnpm/[email protected]
with:
version: 8.x.x

- name: Install Node 18
uses: actions/setup-node@v3
with:
node-version: "18"
registry-url: https://registry.npmjs.org
cache: pnpm
cache-dependency-path: npm/pnpm-lock.yaml

- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
working-directory: npm

- name: Compute tag name
id: tag-name
run: echo "::set-output name=tag-name::${GITHUB_REF#refs/tags/}"

- uses: goreleaser/goreleaser-action@v4
with:
version: 1.19.0
args: release
env:
GITHUB_TOKEN: ${{ secrets.BOT_PUBLIC_GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ steps.tag-name.outputs.tag-name }}

- name: Build pnpm packages
run: make npm
env:
DEPOT_VERSION: ${{ steps.tag-name.outputs.tag-name }}

- name: Release npm packages
run: pnpm publish -r --access public --no-git-checks
working-directory: npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ dist/
/bin
/depot

node_modules

/CHANGELOG.md
.vscode
go.work
go.work.sum
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"prettier.prettierPath": "npm/node_modules/prettier/index.cjs",
"typescript.tsdk": "npm/node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Depot Ventures LLC <[email protected]>
Copyright (c) 2022 Depot Technologies Inc <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ bin/depot:
image:
docker --context=default buildx build --builder default -t ghcr.io/depot/cli:0.0.0-dev --load .

.PHONY: npm
npm:
cd npm && pnpm run clean && pnpm run build

.PHONY: clean
clean:
rm -rf ./bin
Expand Down
3 changes: 3 additions & 0 deletions npm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packages/cli/install.js
packages/*/bin
packages/*/lib
5 changes: 5 additions & 0 deletions npm/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin/
dist/
lib/
pnpm-lock.yaml
packages/**/*.js
30 changes: 30 additions & 0 deletions npm/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
set -ex

node bundle.cjs
pnpm generate-types
pnpm update-versions

chmod +x packages/cli/bin/depot

mkdir -p packages/cli-linux-ia32/bin/
mkdir -p packages/cli-linux-x64/bin/
mkdir -p packages/cli-linux-arm/bin/
mkdir -p packages/cli-linux-arm64/bin/
mkdir -p packages/cli-darwin-x64/bin/
mkdir -p packages/cli-darwin-arm64/bin/
mkdir -p packages/cli-win32-ia32/bin/
mkdir -p packages/cli-win32-x64/bin/
mkdir -p packages/cli-win32-arm/bin/
mkdir -p packages/cli-win32-arm64/bin/

cp ../dist/linux_linux_386/bin/depot packages/cli-linux-ia32/bin/
cp ../dist/linux_linux_amd64_v1/bin/depot packages/cli-linux-x64/bin/
cp ../dist/linux_linux_arm_6/bin/depot packages/cli-linux-arm/bin/
cp ../dist/linux_linux_arm64/bin/depot packages/cli-linux-arm64/bin/
cp ../dist/macos_darwin_amd64_v1/bin/depot packages/cli-darwin-x64/bin/
cp ../dist/macos_darwin_arm64/bin/depot packages/cli-darwin-arm64/bin/
cp ../dist/windows_windows_386/bin/depot.exe packages/cli-win32-ia32/bin/
cp ../dist/windows_windows_amd64_v1/bin/depot.exe packages/cli-win32-x64/bin/
cp ../dist/windows_windows_arm_6/bin/depot.exe packages/cli-win32-arm/bin/
cp ../dist/windows_windows_arm64/bin/depot.exe packages/cli-win32-arm64/bin/
36 changes: 36 additions & 0 deletions npm/bundle.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const esbuild = require('esbuild')

const DEPOT_CLI_VERSION = process.env.DEPOT_CLI_VERSION?.replace('v', '')
if (!DEPOT_CLI_VERSION) throw new Error('Missing DEPOT_CLI_VERSION')

// packages/cli/install.js
esbuild.build({
entryPoints: ['src/install.ts'],
bundle: true,
platform: 'node',
target: 'node14',
outfile: 'packages/cli/install.js',
external: ['@depot/cli'],
})

// packages/cli/lib/main.js
esbuild.build({
entryPoints: ['src/main.ts'],
bundle: true,
platform: 'node',
target: 'node14',
outfile: 'packages/cli/lib/main.js',
external: ['@depot/cli'],
define: {DEPOT_CLI_VERSION: JSON.stringify(DEPOT_CLI_VERSION)},
})

// packages/cli/bin/depot
esbuild.build({
entryPoints: ['src/shim.ts'],
bundle: true,
platform: 'node',
target: 'node14',
outfile: 'packages/cli/bin/depot',
external: ['@depot/cli'],
define: {DEPOT_CLI_VERSION: JSON.stringify(DEPOT_CLI_VERSION)},
})
38 changes: 38 additions & 0 deletions npm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"private": true,
"scripts": {
"build": "./build.sh",
"clean": "rm -rf packages/*/bin packages/*/lib packages/cli/install.js",
"fmt": "prettier --write .",
"fmt:check": "prettier --check .",
"generate-types": "dts-bundle-generator src/main.ts -o packages/cli/lib/main.d.ts --external-inlines execa",
"type-check": "tsc --noEmit",
"update-versions": "node ./update-versions.cjs"
},
"dependencies": {
"execa": "^8.0.1"
},
"devDependencies": {
"@tsconfig/node18": "^18.2.1",
"@types/node": "^20.5.3",
"dts-bundle-generator": "^8.0.1",
"esbuild": "^0.19.2",
"esbuild-register": "^3.4.2",
"prettier": "^3.0.2",
"prettier-plugin-organize-imports": "^3.2.3",
"prettier-plugin-pkg": "^0.18.0",
"tsup": "^7.2.0",
"typescript": "^5.1.6"
},
"prettier": {
"printWidth": 120,
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": false,
"plugins": [
"prettier-plugin-organize-imports",
"prettier-plugin-pkg"
]
}
}
20 changes: 20 additions & 0 deletions npm/packages/cli-darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@depot/cli-darwin-arm64",
"version": "0.0.1-cli.0.0.0-dev",
"description": "The macOS ARM 64-bit binary for @depot/cli.",
"repository": "https://github.com/depot/cli",
"license": "MIT",
"engines": {
"node": ">=14"
},
"cpu": [
"arm64"
],
"os": [
"darwin"
],
"publishConfig": {
"access": "public"
},
"preferUnplugged": true
}
20 changes: 20 additions & 0 deletions npm/packages/cli-darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@depot/cli-darwin-x64",
"version": "0.0.1-cli.0.0.0-dev",
"description": "The macOS Intel 64-bit binary for @depot/cli.",
"repository": "https://github.com/depot/cli",
"license": "MIT",
"engines": {
"node": ">=14"
},
"cpu": [
"x64"
],
"os": [
"darwin"
],
"publishConfig": {
"access": "public"
},
"preferUnplugged": true
}
20 changes: 20 additions & 0 deletions npm/packages/cli-linux-arm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@depot/cli-linux-arm",
"version": "0.0.1-cli.0.0.0-dev",
"description": "The Linux ARM binary for @depot/cli.",
"repository": "https://github.com/depot/cli",
"license": "MIT",
"engines": {
"node": ">=14"
},
"cpu": [
"arm"
],
"os": [
"linux"
],
"publishConfig": {
"access": "public"
},
"preferUnplugged": true
}
20 changes: 20 additions & 0 deletions npm/packages/cli-linux-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@depot/cli-linux-arm64",
"version": "0.0.1-cli.0.0.0-dev",
"description": "The Linux ARM 64-bit binary for @depot/cli.",
"repository": "https://github.com/depot/cli",
"license": "MIT",
"engines": {
"node": ">=14"
},
"cpu": [
"arm64"
],
"os": [
"linux"
],
"publishConfig": {
"access": "public"
},
"preferUnplugged": true
}
20 changes: 20 additions & 0 deletions npm/packages/cli-linux-ia32/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@depot/cli-linux-ia32",
"version": "0.0.1-cli.0.0.0-dev",
"description": "The Linux Intel 32-bit binary for @depot/cli.",
"repository": "https://github.com/depot/cli",
"license": "MIT",
"engines": {
"node": ">=14"
},
"cpu": [
"ia32"
],
"os": [
"linux"
],
"publishConfig": {
"access": "public"
},
"preferUnplugged": true
}
20 changes: 20 additions & 0 deletions npm/packages/cli-linux-x64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@depot/cli-linux-x64",
"version": "0.0.1-cli.0.0.0-dev",
"description": "The Linux Intel 64-bit binary for @depot/cli.",
"repository": "https://github.com/depot/cli",
"license": "MIT",
"engines": {
"node": ">=14"
},
"cpu": [
"x64"
],
"os": [
"linux"
],
"publishConfig": {
"access": "public"
},
"preferUnplugged": true
}
Loading

0 comments on commit a71546e

Please sign in to comment.