Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,33 @@ const templateSummaries: Record<string, string> = {
};

async function runInteractive(opts: CLIOptions): Promise<CLIOptions> {
const pm = await prompts.select({
message: 'What package manager do you use?',
options: [
{
value: '',
label: 'npm',
},
{
value: 'bun',
label: 'Bun',
},
{
value: 'pnpm',
label: 'pnpm',
},
{
value: 'yarn',
label: 'yarn',
}
],
initialValue: opts.template
});

if (prompts.isCancel(pm)) {
cancelInteractive();
}

const template = await prompts.select({
message: 'Select a changelog tool',
options: [
Expand All @@ -184,7 +211,7 @@ async function runInteractive(opts: CLIOptions): Promise<CLIOptions> {
hint: 'Automate changelog generation and releases using changesets'
}
],
initialValue: opts.template
initialValue: opts.template,
});

if (prompts.isCancel(template)) {
Expand Down Expand Up @@ -223,6 +250,7 @@ async function runInteractive(opts: CLIOptions): Promise<CLIOptions> {
return {
...opts,
template,
pm,
...userOptions
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sade from 'sade';
import {runCLI} from './cli.js';

const cli = sade('@e18e/setup-publish', true);
const CLI_VERSION = '0.0.0-dev';
const CLI_VERSION = '0.0.10';

/*
* - changesets
Expand Down
11 changes: 10 additions & 1 deletion src/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,19 @@ export async function createTemplate(opts: CLIOptions): Promise<void> {

// Shouldn't ever happen but just in case
if (!templates.includes(opts.template)) {
prompts.log.error(`❌ Template for current configuration not found`);
return;
}

const templatePath = path.join(templatesDir, `${opts.template}.yml`);
if (opts.pm && !templates.includes(`${opts.template}+${opts.pm}`)) {
prompts.log.warn(`⚠️ Template for your package manager does not exist. Falling back to npm`);
opts.pm = '';
}

const templatePath = opts.pm
? path.join(templatesDir, `${opts.template}.yml`)
: path.join(templatesDir, `${opts.template}+${opts.pm}.yml`);

let templateContent: string;

try {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export interface CLIOptions {
env: string | undefined;
interactive: boolean;
template: string;
pm: string;
}
51 changes: 51 additions & 0 deletions templates/changesets+bun.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Publish to npm
permissions: {}
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile --ignore-scripts
- name: Run tests
run: bun test
publish:
needs:
- test
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
id-token: write
outputs:
tarball: ${{ steps.pack.outputs.tarball }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile --ignore-scripts
- run: bun run build
- name: Create Release or Publish
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
with:
publish: bunx changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: "" # Workaround. See https://github.com/changesets/changesets/issues/1152#issuecomment-3190884868
17 changes: 12 additions & 5 deletions templates/changesets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
- name: Setup Node
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 24
cache: npm
- run: npm ci --ignore-scripts
- run: npm test
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Run tests
run: npm test
publish:
needs:
- test
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -31,11 +36,13 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
- name: Setup Node
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 24
package-manager-cache: false
- run: npm ci --ignore-scripts
- name: Install dependencies
run: npm ci --ignore-scripts
- run: npm run build
- name: Create Release or Publish
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
Expand Down
76 changes: 76 additions & 0 deletions templates/default+bun.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Publish to npm
permissions: {}
on:
release:
types:
- published
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile --ignore-scripts
- name: Run tests
run: bun test
build:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
tarball: ${{ steps.pack.outputs.tarball }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile --ignore-scripts
- run: bun run build
- run: bun pm version $TAG_NAME --git-tag-version=false
env:
TAG_NAME: ${{ github.ref_name }}
- id: pack
run: |-
TARBALL=$(bun pm pack)
echo "tarball=$TARBALL" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: tarball
path: ${{ steps.pack.outputs.tarball }}
publish:
needs:
- test
- build
runs-on: ubuntu-latest
permissions:
id-token: write
env:
TARBALL: ${{ needs.build.outputs.tarball }}
steps:
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: tarball
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 24
package-manager-cache: false
- run: bun publish --provenance --access public --tag next $TARBALL
if: github.event.release.prerelease
env:
TARBALL: ${{ needs.build.outputs.tarball }}
- run: bun publish --provenance --access public $TARBALL
if: "!github.event.release.prerelease"
env:
TARBALL: ${{ needs.build.outputs.tarball }}
18 changes: 12 additions & 6 deletions templates/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
- name: Setup Node
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 24
cache: npm
- run: npm ci --ignore-scripts
- run: npm test
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Run tests
run: npm test
build:
runs-on: ubuntu-latest
permissions:
Expand All @@ -29,11 +32,13 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
- name: Setup Node
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 24
package-manager-cache: false
- run: npm ci --ignore-scripts
- name: Install dependencies
run: npm ci --ignore-scripts
- run: npm run build
- run: npm version $TAG_NAME --git-tag-version=false
env:
Expand All @@ -59,7 +64,8 @@ jobs:
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: tarball
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
- name: Setup Node
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: 24
package-manager-cache: false
Expand Down
Loading