Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
ci: Add manual republish of packages
  • Loading branch information
nzakas committed Feb 13, 2025
commit c44323a3a61de468bc16e80a60ceee86af8f676c
81 changes: 81 additions & 0 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Manual Package Publish

on:
workflow_dispatch:
inputs:
package:
description: "Package to publish"
required: true
type: choice
options:
# NOTE: Package names are automatically generated. Do not manually edit.
# packages-start
- compat
- config-array
- core
- migrate-config
- object-schema
- plugin-kit
# packages-end

permissions:
contents: read
id-token: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
run: npm install

- name: Get latest release tag
id: get-latest-release
run: |
LATEST_TAG=$(git tag -l "${{ inputs.package }}*" --sort=-v:refname | head -n 1)
echo "latest_tag=${LATEST_TAG}" >> $GITHUB_OUTPUT

- name: Check out latest release
id: checkout-latest-release
run: |
git fetch --tags origin ${{ steps.get-latest-release.outputs.latest_tag }}
git checkout ${{ steps.get-latest-release.outputs.latest_tag }}

- name: Get package version
id: get-version
run: |
VERSION=$(node -p "require('./${{ inputs.package }}/package.json').version")
echo "version=${VERSION}" >> $GITHUB_OUTPUT

- name: Build
run: npm run build

- name: Publish to npm
run: npm publish -w packages/${{ inputs.package }} --provenance
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

- name: Publish to JSR
if: ${{ inputs.package != 'migrate-config' }}
run: npx jsr publish
working-directory: packages/${{ inputs.package }}

- name: Post Release Announcement
run: npx @humanwhocodes/crosspost -t -b -m "eslint/${{ inputs.package }} v${{ steps.get-version.outputs.version }} has been released!\n\nhttps://github.com/eslint/rewrite/releases/tag/${{ steps.get-latest-release.outputs.latest_tag }}"
env:
TWITTER_API_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_API_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
MASTODON_HOST: ${{ secrets.MASTODON_HOST }}
BLUESKY_IDENTIFIER: ${{ vars.BLUESKY_IDENTIFIER }}
BLUESKY_PASSWORD: ${{ secrets.BLUESKY_PASSWORD }}
BLUESKY_HOST: ${{ vars.BLUESKY_HOST }}
29 changes: 29 additions & 0 deletions tools/new-pkg.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,35 @@ issueTemplateFiles.forEach(file => {
console.log("✅ Updated", filePath);
});

//-----------------------------------------------------------------------------
// Update manual-publish.yml
//-----------------------------------------------------------------------------

console.log("\nUpdating manual-publish.yml...");

const publishPath = "./.github/workflows/manual-publish.yml";
const publishContent = readFileSync(publishPath, "utf8");
const publishLines = publishContent.split(/\r?\n/gu);
const publishStartIndex = publishLines.findIndex(line =>
line.includes("# packages-start"),
);
const publishEndIndex = publishLines.findIndex(line =>
line.includes("# packages-end"),
);
const newPublishLines = packageNames.map(
packageName => `${" ".repeat(20)}- ${packageName}`,
);

publishLines.splice(
publishStartIndex + 1,
publishEndIndex - publishStartIndex - 1,
...newPublishLines,
);

writeFileSync(publishPath, publishLines.join("\n"), "utf8");

console.log("✅ Updated", publishPath);

//-----------------------------------------------------------------------------
// Update README
//-----------------------------------------------------------------------------
Expand Down