Skip to content

Commit

Permalink
npm deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
ottomated committed Mar 4, 2023
1 parent aac8c12 commit 004569c
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 7 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,22 @@ jobs:
mv target/i686-pc-windows-gnu/release/create-o7-app.exe artifacts/create-o7-app-win32.exe
mv target/x86_64-apple-darwin/release/create-o7-app artifacts/create-o7-app-macos
mv target/aarch64-apple-darwin/release/create-o7-app artifacts/create-o7-app-macos-arm64
- name: Release
- name: Get version
id: get_version
run: echo "version=$(cargo pkgid | cut -d@ -f2)" >> $GITHUB_OUTPUT
- name: Release Binaries
uses: softprops/action-gh-release@v1
with:
tag_name: '0.0.0'
tag_name: ${{ steps.get_version.outputs.version }}
files: artifacts/*
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Publish NPM Package
run: |
cd pkg
jq '.version = "${{ steps.get_version.outputs.version }}"' package.json > tmp && mv tmp package.json
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
npm publish
5 changes: 0 additions & 5 deletions package.json

This file was deleted.

50 changes: 50 additions & 0 deletions pkg/bin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

const { Binary } = require('binary-install');
const os = require('os');
const { version } = require('./package.json');

const platforms = [
{
type: 'Windows_NT',
arch: 'x64',
file: 'win64.exe'
},
{
type: 'Windows_NT',
arch: 'ia32',
file: 'win32.exe'
},
{
type: 'Linux',
arch: 'x64',
file: 'linux'
},
{
type: 'Darwin',
arch: 'x64',
file: 'macos'
},
{
type: 'Darwin',
arch: 'arm64',
file: 'macos-arm64'
},
];

const type = os.type();
const arch = os.arch();
const supported = platforms.find(
(p) => p.type === type && p.arch === arch
);
if (!supported) {
throw new Error(
`Unsupported platform: ${type} ${arch}`
);
}

module.exports = {
bin: new Binary(
'create-o7-app',
`https://github.com/ottomated/create-o7-app/releases/download/v${version}/create-o7-app-${supported.file}`
),
};
4 changes: 4 additions & 0 deletions pkg/install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node

const bin = require("./bin");
bin.install();
28 changes: 28 additions & 0 deletions pkg/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "create-o7-app",
"version": "TEMPLATE",
"description": "Create web applications with the o7 stack",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ottomated/create-o7-app.git"
},
"keywords": [
"create-o7-app",
"o7",
"svelte",
"sveltekit",
"tailwind",
"tRPC",
"typescript",
"planetscale",
"prisma",
"kysely"
],
"bin": {
"create-o7-app": "./run.js"
},
"scripts": {
"postinstall": "node ./install.js"
}
}
4 changes: 4 additions & 0 deletions pkg/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node

const bin = require("./bin");
bin.run();

0 comments on commit 004569c

Please sign in to comment.