diff --git a/build/announce/announce.ts b/build/announce/announce.ts index 70a4744bc72de7ea7435fd0644826dfb76046cfe..ee5649e291d325616596301f150a10c147a59ae7 100644 --- a/build/announce/announce.ts +++ b/build/announce/announce.ts @@ -7,18 +7,19 @@ interface AnnounceOpts { out: string releaseDir: string apkgFilenames: string[] + /** Pack title, e.g. Tapir Sciences */ + title: string + /** Full repository name on Gitlab, e.g. kartenaale/sinologie-anki-pack */ + repo: string } export async function announce (opts: AnnounceOpts): Promise<void> { const version = getReleaseVersion(opts.releaseDir) const announcement = [ - `# Sinologie Anki Pack ${version} ist released! 🎉`, - `## Details zum Release:\n${linkToReleaseDetails(version)}`, - `## Download komplettes Pack als ZIP:\n${ - allArtifactsZipDownload() - }`, + `# ${opts.title} ${version} ist released! 🎉`, + `## Details zum Release:\n${linkToReleaseDetails(opts.repo, version)}`, '## Download einzelne APKGs:', - ...(await linksToApkgs(opts.releaseDir, opts.apkgFilenames)) + ...(await linksToApkgs(opts.repo, opts.releaseDir, opts.apkgFilenames)) ].join('\n\n') await writeFile(opts.out, announcement, { encoding: 'utf-8' }) } @@ -31,15 +32,18 @@ function getReleaseVersion (dir: string): string { return dir.substring(dashIdx + 1) } -function linkToReleaseDetails (version: string): string { +function linkToReleaseDetails (repo: string, version: string): string { return ( - `https://gitlab.phaidra.org/kartenaale/sinologie-anki-pack/-/releases/${ + `https://gitlab.phaidra.org/${ + repo + }/-/releases/${ version }` ) } async function linksToApkgs ( + repo: string, releaseDir: string, apkgFilenames: string[] ): Promise<string[]> { @@ -52,26 +56,22 @@ async function linksToApkgs ( return `### ${ basename(path, '.apkg').replace(/-/g, ' ').replace('fuer', 'für') }\n${ - rawArtifactDownload(path) + rawArtifactDownload(repo, path) }` }) } -function rawArtifactDownload (path: string): string { +function rawArtifactDownload (repo: string, path: string): string { if (path === '') { throw new Error('path required') } - return `https://gitlab.phaidra.org/kartenaale/sinologie-anki-pack/-/jobs/${ + return `https://gitlab.phaidra.org/${ + repo + }/-/jobs/${ getCiJobId() }/artifacts/raw/${encodeURIComponent(path)}` } -function allArtifactsZipDownload (): string { - return `https://gitlab.phaidra.org/kartenaale/sinologie-anki-pack/-/jobs/${ - getCiJobId() - }/artifacts/download` -} - function getCiJobId (): string { return process.env.CI_JOB_ID ?? 'job-id-unavailable' } diff --git a/build/announce/run.ts b/build/announce/run.ts index 98cb5c534f6e85e8260b2d0f21b403f7951472f3..3c0c329813092180973dd5690b65967089bcd9d2 100644 --- a/build/announce/run.ts +++ b/build/announce/run.ts @@ -2,12 +2,19 @@ import { exit } from 'process' import { announce } from './announce' import { parseArgs } from 'util' -const { values: { out, releaseDir, apkg } } = parseArgs({ +const { values: { out, title, repo, releaseDir, apkg } } = parseArgs({ options: { out: { type: 'string', short: 'o' }, + title: { + type: 'string' + }, + repo: { + type: 'string', + short: 'r' + }, releaseDir: { type: 'string', short: 'p' @@ -20,6 +27,8 @@ const { values: { out, releaseDir, apkg } } = parseArgs({ }) if (out === undefined || + title === undefined || + repo === undefined || releaseDir === undefined || apkg === undefined || apkg.length === 0) { @@ -27,7 +36,7 @@ if (out === undefined || throw new Error(`error: missing arguments, exiting.\nargs:${given}`) } -void announce({ out, releaseDir, apkgFilenames: apkg }).then( +void announce({ out, title, repo, releaseDir, apkgFilenames: apkg }).then( undefined, e => { console.error(e) diff --git a/make/announce.mk b/make/announce.mk index 309ae694431c9380bf3301a5009bc6b14da1c9f8..fe3cfe58d829a0d7b0c49b6fca80ce65c94523a1 100644 --- a/make/announce.mk +++ b/make/announce.mk @@ -8,8 +8,8 @@ announce: $(ANNOUNCEMENT_FILE) $(ANNOUNCEMENT_FILE): $(ANNOUNCE) $(PYTHON_NEEDED) build/export_apkgs.py $(ANNOUNCE) \ --out $@ \ - --releaseDir $(RELEASE_DIR) \ + --title '$(PACK_TITLE)' \ + --repo $(GITLAB_REPO) \ + --releaseDir $(DOWNLOAD_PREFIX)$(RELEASE_DIR) \ $(addprefix --apkg , \ - $(patsubst %,'%', \ - $(shell PIPENV_VENV_IN_PROJECT=1 pipenv run \ - build/export_apkgs.py --dry-run -c content -t no))) + $(patsubst %,'%',$(APKGS))) diff --git a/make/apkgs.mk b/make/apkgs.mk index 12179efdfce972ad2961caa83b3c7a2154f6dd61..499222957fc65fed0a58e425ed6c02f8449fd26e 100644 --- a/make/apkgs.mk +++ b/make/apkgs.mk @@ -1,4 +1,3 @@ -CONTENT_DIR ?= content APKG_TEST_DIR := test/build APKG_TEST_OK_FLAG := $(BUILD_PREFIX).apkg-test-ok APKG_TEST_FILES := $(shell find $(APKG_TEST_DIR) -name '*.py' -o -name '*.yaml' -o -name '*.html' -o -name '*.csv') diff --git a/make/defs.mk b/make/defs.mk index 52efe7fde7a4cf20d09a8b6c28ccb514b37444a8..fe0c93c55cb6253b50d53315028c7d4bf3bc3291 100644 --- a/make/defs.mk +++ b/make/defs.mk @@ -11,3 +11,14 @@ BUILD_PREFIX := $(and $(filter-out . ./,$(BUILD_PREFIX)),$(BUILD_PREFIX)/) # some build subprocesses need this, e.g. the JS proxy for parcel needs to # know where to load the chardata from export BUILD_PREFIX + +# directory with apkg data and specs, can be overridden +CONTENT_DIR ?= content + +# name of the repository on gitlab for download links +GITLAB_REPO ?= kartenaale/sinologie-anki-pack + +PACK_TITLE ?= Sinologie Anki Pack +# part before the npm version in the release directory name +RELEASE_DIR_STEM ?= sinologie-anki-pack +VERSION ?= $(shell grep '"version":' package.json -m 1 | cut -d '"' -f 4) \ No newline at end of file diff --git a/make/release.mk b/make/release.mk index daed84d6fc3d923998ff2e0a9650b84c27a6e73c..3fe25cd1c8584a26a5556fc8e95ca2d8d3b56391 100644 --- a/make/release.mk +++ b/make/release.mk @@ -1,6 +1,3 @@ -# part before the npm version in the release directory name -RELEASE_DIR_STEM ?= sinologie-anki-pack -VERSION ?= $(shell grep '"version":' package.json -m 1 | cut -d '"' -f 4) RELEASE_DIR := $(BUILD_PREFIX)$(RELEASE_DIR_STEM)-$(VERSION) RELEASE_ZIP := $(RELEASE_DIR).zip