-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial version of
npm init neon --lib
- generates necessary boilerplate to be a portable Node library implemented in Rust - uses TS by default (can be disabled) - generates GitHub Actions boilerplate by default (can be disabled) to make publishing push-button
- Loading branch information
Showing
27 changed files
with
4,341 additions
and
449 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{{#if package.isLibrary}} | ||
{{#if packageSpec.library}} | ||
platforms | ||
{{/if}} |
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,4 @@ | ||
NODE_VERSION=18.x | ||
NPM_REGISTRY=https://registry.npmjs.org | ||
ACTIONS_USER=github-actions | ||
ACTIONS_EMAIL=github-actions@github.com |
124 changes: 124 additions & 0 deletions
124
pkgs/create-neon/data/templates/ci/github/build.yml.hbs
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,124 @@ | ||
name: Build | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
branch: | ||
description: 'Branch to check out' | ||
required: false | ||
type: string | ||
default: {{#$}} github.event.repository.default_branch {{/$}} | ||
update-version: | ||
description: 'Update version before building?' | ||
required: false | ||
type: boolean | ||
default: false | ||
version: | ||
description: 'Version update (ignored if update-version if false)' | ||
required: false | ||
type: string | ||
default: 'patch' | ||
github-release: | ||
description: 'Publish GitHub release?' | ||
required: false | ||
type: boolean | ||
default: false | ||
|
||
jobs: | ||
matrix: | ||
name: Matrix | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: {{#$}} steps.matrix.outputs.result {{/$}} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@{{versions.actions.checkout}} | ||
with: | ||
token: {{#$}} secrets.TAG_TOKEN || github.token {{/$}} | ||
ref: {{#$}} inputs.branch {{/$}} | ||
- name: Set Environment Variables | ||
uses: falti/dotenv-action@{{versions.actions.dotenv}} | ||
with: | ||
path: ./.github/workflows/.env | ||
export-variables: true | ||
keys-case: bypass | ||
- name: Install Node | ||
uses: actions/setup-node@{{versions.actions.setupNode}} | ||
with: | ||
node-version: {{#$}} env.NODE_VERSION {{/$}} | ||
registry-url: {{#$}} env.NPM_REGISTRY {{/$}} | ||
cache: npm | ||
- name: Install Dependencies | ||
shell: bash | ||
run: npm ci | ||
- name: Install cargo-messages | ||
shell: bash | ||
run: npm ci | ||
working-directory: ./pkgs/cargo-messages | ||
- name: Look Up Matrix Data | ||
id: matrixData | ||
shell: bash | ||
run: | | ||
echo "json=$(node ../../dist/cli ci github | jq -rc)" >> "$GITHUB_OUTPUT" | ||
working-directory: ./pkgs/cargo-messages | ||
- name: Compute Matrix | ||
id: matrix | ||
uses: actions/github-script@{{versions.actions.githubScript}} | ||
with: | ||
script: | | ||
const platforms = {{#$}} steps.matrixData.outputs.json {{/$}}; | ||
const macOS = platforms.macOS.map(platform => { | ||
return { os: "macos-latest", platform, cross: false }; | ||
}); | ||
const windows = platforms.Windows.map(platform => { | ||
return { os: "windows-latest", platform, cross: false }; | ||
}); | ||
const linux = platforms.Linux.map(platform => { | ||
return { os: "ubuntu-latest", platform, cross: true }; | ||
}); | ||
return [...macOS, ...windows, ...linux]; | ||
|
||
binaries: | ||
name: Binaries | ||
needs: [matrix] | ||
strategy: | ||
matrix: | ||
cfg: {{#$}} fromJSON(needs.matrix.outputs.matrix) {{/$}} | ||
runs-on: {{#$}} matrix.cfg.os {{/$}} | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@{{versions.actions.checkout}} | ||
with: | ||
fetch-depth: 0 | ||
- name: Set Environment Variables | ||
uses: falti/dotenv-action@{{versions.actions.dotenv}} | ||
with: | ||
path: ./.github/workflows/.env | ||
export-variables: true | ||
keys-case: bypass | ||
- name: Diagnostics | ||
shell: bash | ||
run: git log -10 | ||
- name: Install Dependencies | ||
shell: bash | ||
run: npm ci | ||
- name: Update Version | ||
if: {{#$}} inputs.update-version {{/$}} | ||
shell: bash | ||
run: | | ||
git config --global user.name $ACTIONS_USER | ||
git config --global user.email $ACTIONS_EMAIL | ||
npm version {{#$}} inputs.version {{/$}} -m "v%s" | ||
- name: Check Versions | ||
shell: bash | ||
run: ./test/lint/check-versions.sh | ||
- name: Build | ||
uses: neon-actions/build@{{versions.actions.neonBuild}} | ||
with: | ||
working-directory: ./pkgs/cargo-messages | ||
node-version: {{#$}} env.NODE_VERSION {{/$}} | ||
use-cross: {{#$}} !!matrix.cfg.cross {{/$}} | ||
platform: {{#$}} matrix.cfg.platform {{/$}} | ||
github-release: {{#$}} inputs.github-release {{/$}} |
40 changes: 40 additions & 0 deletions
40
pkgs/create-neon/data/templates/ci/github/comments.yml.hbs
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,40 @@ | ||
name: Comments | ||
|
||
run-name: | | ||
{{#$}} (github.event.issue.pull_request | ||
&& contains(github.event.comment.body, '/build-all') | ||
&& format('Full build (PR #{0})', github.event.issue.number)) | ||
|| 'Issue comment (no action)' {{/$}} | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
setup: | ||
name: Setup | ||
runs-on: ubuntu-latest | ||
if: {{#$}} github.event.issue.pull_request && contains(github.event.comment.body, '/build-all') {{/$}} | ||
outputs: | ||
branch: {{#$}} steps.pr-ref.outputs.branch || github.event.repository.default_branch {{/$}} | ||
steps: | ||
- name: PR Branch | ||
if: {{#$}} github.event.issue.pull_request {{/$}} | ||
id: pr-ref | ||
shell: bash | ||
run: echo "branch=$(gh pr view $PR_NO --repo $REPO --json headRefName --jq '.headRefName')" >> "$GITHUB_OUTPUT" | ||
env: | ||
REPO: {{#$}} github.repository {{/$}} | ||
PR_NO: {{#$}} github.event.issue.number {{/$}} | ||
GITHUB_TOKEN: {{#$}} secrets.GITHUB_TOKEN {{/$}} | ||
|
||
build-all: | ||
name: Build | ||
needs: [setup] | ||
permissions: | ||
contents: write | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
branch: {{#$}} needs.setup.outputs.branch {{/$}} | ||
update-version: true | ||
github-release: false |
5 changes: 5 additions & 0 deletions
5
pkgs/create-neon/data/templates/ci/github/manifest/scripts.json.hbs
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,5 @@ | ||
{ | ||
"tag": "npm version -m 'v%s'", | ||
"posttag": "git push --follow-tags", | ||
"dryrun": "gh workflow run publish.yml -f dryrun=true" | ||
} |
Oops, something went wrong.