Skip to content

Commit

Permalink
chore: publishing initium-cli as an NPM package (#99)
Browse files Browse the repository at this point in the history
Co-authored-by: Luca Lanziani <[email protected]>
  • Loading branch information
Pehesi97 and LucaLanziani committed Sep 21, 2023
1 parent 798a813 commit 1677fae
Show file tree
Hide file tree
Showing 14 changed files with 3,806 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/onbranch.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Build on branch

on:
push:
branches-ignore:
- "main"
push:
branches-ignore:
- "main"

jobs:
cli:
Expand All @@ -23,4 +23,4 @@ jobs:
env:
INITIUM_APP_NAME: initium-cli
INITIUM_REGISTRY_USER: ${{ github.actor }}
INITIUM_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
INITIUM_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/onmain.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Deploy on main

on:
on:
push:
branches:
- main
Expand All @@ -21,4 +21,4 @@ jobs:
env:
INITIUM_APP_NAME: initium-cli
INITIUM_REGISTRY_USER: ${{ github.actor }}
INITIUM_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
INITIUM_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,34 @@ jobs:
private_key: ${{ secrets.RELEASE_PLEASE_APP_PRIVATE_KEY }}

- uses: google-github-actions/release-please-action@v3
id: release_please
with:
release-type: go
token: ${{ steps.get_installation_token.outputs.token }}
bump-minor-pre-major: true
package-name: release-please-action
extra-files: |
npm/package.json
- name: Get commit author
id: commit_author
run: |
author=$(gh pr list --search ${{ github.sha }} --state merged --json mergedBy --jq '.[0].mergedBy.login'
echo "author=${author}" >> $$GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }}

- uses: actions/setup-node@v3
# This sets up the .npmrc file for publishing to npm
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"

# we want the good pipefail behaviour https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
- shell: bash
run: |
cd npm
./publish.sh
env:
NPM_TOKEN: ${{ secrets[format('NPM_TOKEN_{0}', steps.commit_author.outputs.author)] || secrets.NPM_TOKEN }}
OPTIC_TOKEN: ${{ secrets[format('OPTIC_TOKEN_{0}', steps.commit_author.outputs.author)] || secrets.OPTIC_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
# run only against tags
tags:
- '*'
- "*"

permissions:
contents: write
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ Dockerfile.initium
initium_onmain.yaml
initium_onbranch.yaml
dist/

node_modules
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ A single static binary that can run on any CI to build your code and deploy it i

All with a nice development workflow in mind like ephemeral environment for your PRs.

### Running the CLI

The CLI is currently published on [NPM](https://www.npmjs.com/package/initium). You can run it using

```
npx initium
```

That will install the Initium CLI in your folder's `node_modules`.

We recommend you not to try installing the CLI globally if you don't use a Node.js version manager (like `nvm`), as you can run into permission errors.

### Pre-requisites

1. GoLang
Expand Down
1 change: 1 addition & 0 deletions npm/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
publish.sh
7 changes: 7 additions & 0 deletions npm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Publish the initium CLI on NPM

This folder is here to generate an npm package that will allow user to run initium with either npm or npx.

NOTE: This package doesn't contain the binaries.

You can check the code in the `script` folder to see how this package will detect the platform and architecture of your machine and download the relevant binary from the github releases of this repo.
Loading

0 comments on commit 1677fae

Please sign in to comment.