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
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ jobs:
run: yarn lint
- name: test
run: yarn test
publish-packages-dry-run:
needs: build_and_test
uses: ./.github/workflows/publish-packages.yml
with:
dry-run: true
publish-registry-dry-run:
needs: build_and_test
uses: ./.github/workflows/publish-registry.yml
with:
dry-run: true
retag-dry-run:
needs: build_and_test
uses: ./.github/workflows/retag.yml
with:
dry-run: true
publish_alpha:
name: publish alpha release
runs-on: ubuntu-latest
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/publish-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish packages
#description: Find changed @types packages in the DT repo and publish them to npm.
on:
workflow_call:
inputs:
dry-run:
type: boolean
workflow_dispatch:
inputs:
dry-run:
type: boolean
jobs:
publish-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Parse declarations
run: yarn workspace @definitelytyped/publisher parse
- uses: actions/cache@v3
with:
path: packages/utils/cache/
key: cache-${{ github.run_id }}
restore-keys: cache-
- name: Calculate versions
run: yarn workspace @definitelytyped/publisher calculate-versions
- name: Generate packages
run: yarn workspace @definitelytyped/publisher generate
- name: Publish packages${{ (inputs || github.event.inputs).dry-run && ' dry run' || '' }}
run: yarn workspace @definitelytyped/publisher publish-packages${{ (inputs || github.event.inputs).dry-run && ' --dry' || '' }}
env:
GH_API_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.NPM_RETAG_TOKEN }}
- if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ github.job }}
path: packages/definitions-parser/data/
14 changes: 12 additions & 2 deletions .github/workflows/publish-registry.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
name: Publish registry
#description: Publish the types-registry package to npm (a list of all @types packages in the DT repo).
on:
schedule:
# https://crontab.guru/#0_0_*_*_0
- cron: 0 0 * * 0
workflow_call:
inputs:
dry-run:
type: boolean
workflow_dispatch:
inputs:
dry-run:
type: boolean
jobs:
publish-registry:
if: github.event_name != 'schedule' || github.repository == 'microsoft/DefinitelyTyped-tools'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -21,11 +30,12 @@ jobs:
path: packages/utils/cache/
key: cache-${{ github.run_id }}
restore-keys: cache-
- name: Publish registry
run: yarn workspace @definitelytyped/publisher publish-registry
- name: Publish registry${{ (inputs || github.event.inputs).dry-run && ' dry run' || '' }}
run: yarn workspace @definitelytyped/publisher publish-registry${{ (inputs || github.event.inputs).dry-run && ' --dry' || '' }}
env:
NPM_TOKEN: ${{ secrets.NPM_RETAG_TOKEN }}
- if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ github.job }}
path: packages/definitions-parser/data/
39 changes: 39 additions & 0 deletions .github/workflows/retag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Update npm tags
#description: Refresh tags on all DT-published packages in the @types scope.
on:
schedule:
# https://crontab.guru/#0_0_*_*_0
- cron: 0 0 * * 0
workflow_call:
inputs:
dry-run:
type: boolean
workflow_dispatch:
inputs:
dry-run:
type: boolean
jobs:
retag:
if: github.event_name != 'schedule' || github.repository == 'microsoft/DefinitelyTyped-tools'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn build
- uses: actions/cache@v3
with:
path: packages/utils/cache/
key: cache-${{ github.run_id }}
restore-keys: cache-
- name: Update npm tags${{ (inputs || github.event.inputs).dry-run && ' dry run' || '' }}
run: yarn retag${{ (inputs || github.event.inputs).dry-run && ' --dry' || '' }}
env:
NPM_TOKEN: ${{ secrets.NPM_RETAG_TOKEN }}
- if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ github.job }}
path: packages/definitions-parser/data/
35 changes: 0 additions & 35 deletions .github/workflows/update-ts-version-tags.yml

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"format": "prettier --write 'packages/**/*.ts'",
"test": "jest",
"build": "tsc -b .",
"retag": "node packages/retag/dist/retag.js"
"retag": "node --require source-map-support/register packages/retag/"
},
"devDependencies": {
"@types/jest": "^25.1.3",
Expand Down
5 changes: 3 additions & 2 deletions packages/publisher/src/generate-packages.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { makeTypesVersionsForPackageJson } from "@definitelytyped/header-parser";
import { emptyDir, mkdir, mkdirp, readFileSync } from "fs-extra";
import path = require("path");
import process from "process";
import yargs = require("yargs");

import { defaultLocalOptions } from "./lib/common";
import { defaultLocalOptions, defaultRemoteOptions } from "./lib/common";
import { outputDirPath, sourceBranch } from "./lib/settings";
import {
assertNever,
Expand Down Expand Up @@ -42,7 +43,7 @@ if (!module.parent) {
const tgz = !!yargs.argv.tgz;
logUncaughtErrors(async () => {
const log = loggerWithErrors()[0];
const dt = await getDefinitelyTyped(defaultLocalOptions, log);
const dt = await getDefinitelyTyped(process.env.GITHUB_ACTIONS ? defaultRemoteOptions : defaultLocalOptions, log);
const allPackages = await AllPackages.read(dt);
await generatePackages(dt, allPackages, await readChangedPackages(allPackages), tgz);
});
Expand Down
10 changes: 7 additions & 3 deletions packages/publisher/src/publish-packages.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import process from "process";
import applicationinsights = require("applicationinsights");
import * as yargs from "yargs";

import { defaultLocalOptions } from "./lib/common";
import { defaultLocalOptions, defaultRemoteOptions } from "./lib/common";
import { publishNotNeededPackage, publishTypingsPackage } from "./lib/package-publisher";
import { getDefinitelyTyped, AllPackages } from "@definitelytyped/definitions-parser";
import {
Expand All @@ -19,7 +20,10 @@ import { getSecret, Secret } from "./lib/secrets";
if (!module.parent) {
const dry = !!yargs.argv.dry;
logUncaughtErrors(async () => {
const dt = await getDefinitelyTyped(defaultLocalOptions, loggerWithErrors()[0]);
const dt = await getDefinitelyTyped(
process.env.GITHUB_ACTIONS ? defaultRemoteOptions : defaultLocalOptions,
loggerWithErrors()[0]
);
await publishPackages(
await readChangedPackages(await AllPackages.read(dt)),
dry,
Expand All @@ -42,7 +46,7 @@ export default async function publishPackages(
log("=== Publishing packages ===");
}

const client = await NpmPublishClient.create(await getSecret(Secret.NPM_TOKEN), undefined);
const client = await NpmPublishClient.create(dry ? "" : await getSecret(Secret.NPM_TOKEN), undefined);

for (const cp of changedPackages.changedTypings) {
log(`Publishing ${cp.pkg.desc}...`);
Expand Down
3 changes: 0 additions & 3 deletions packages/retag/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
"@types/yargs": "^15.0.5"
},
"main": "dist/index.js",
"bin": {
"retag": "./dist/retag.js"
},
"publishConfig": {
"access": "public"
}
Expand Down
10 changes: 6 additions & 4 deletions packages/retag/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

import assert = require("assert");
import yargs from "yargs";
import process = require("process");
Expand Down Expand Up @@ -49,10 +47,14 @@ async function main() {
*/
async function tag(dry: boolean, nProcesses: number, name?: string) {
const log = loggerWithErrors()[0];
const options = { definitelyTypedPath: "../DefinitelyTyped", progress: true, parseInParallel: true };
const options = process.env.GITHUB_ACTIONS
? { definitelyTypedPath: undefined, progress: false, parseInParallel: false }
: { definitelyTypedPath: "../DefinitelyTyped", progress: true, parseInParallel: true };
await parseDefinitions(
await getDefinitelyTyped(options, log),
{ nProcesses: nProcesses || os.cpus().length, definitelyTypedPath: "../DefinitelyTyped" },
options.parseInParallel
? { nProcesses: nProcesses || os.cpus().length, definitelyTypedPath: "../DefinitelyTyped" }
: undefined,
log
);

Expand Down