Skip to content
Snippets Groups Projects
Commit 7d3d4e6e authored by Philipp Stadler's avatar Philipp Stadler
Browse files

chore: more announcement customization

parent af48aa15
No related branches found
No related tags found
1 merge request!134chore: more announcement customization
Pipeline #13769 passed
...@@ -7,18 +7,19 @@ interface AnnounceOpts { ...@@ -7,18 +7,19 @@ interface AnnounceOpts {
out: string out: string
releaseDir: string releaseDir: string
apkgFilenames: 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> { export async function announce (opts: AnnounceOpts): Promise<void> {
const version = getReleaseVersion(opts.releaseDir) const version = getReleaseVersion(opts.releaseDir)
const announcement = [ const announcement = [
`# Sinologie Anki Pack ${version} ist released! 🎉`, `# ${opts.title} ${version} ist released! 🎉`,
`## Details zum Release:\n${linkToReleaseDetails(version)}`, `## Details zum Release:\n${linkToReleaseDetails(opts.repo, version)}`,
`## Download komplettes Pack als ZIP:\n${
allArtifactsZipDownload()
}`,
'## Download einzelne APKGs:', '## Download einzelne APKGs:',
...(await linksToApkgs(opts.releaseDir, opts.apkgFilenames)) ...(await linksToApkgs(opts.repo, opts.releaseDir, opts.apkgFilenames))
].join('\n\n') ].join('\n\n')
await writeFile(opts.out, announcement, { encoding: 'utf-8' }) await writeFile(opts.out, announcement, { encoding: 'utf-8' })
} }
...@@ -31,15 +32,18 @@ function getReleaseVersion (dir: string): string { ...@@ -31,15 +32,18 @@ function getReleaseVersion (dir: string): string {
return dir.substring(dashIdx + 1) return dir.substring(dashIdx + 1)
} }
function linkToReleaseDetails (version: string): string { function linkToReleaseDetails (repo: string, version: string): string {
return ( return (
`https://gitlab.phaidra.org/kartenaale/sinologie-anki-pack/-/releases/${ `https://gitlab.phaidra.org/${
repo
}/-/releases/${
version version
}` }`
) )
} }
async function linksToApkgs ( async function linksToApkgs (
repo: string,
releaseDir: string, releaseDir: string,
apkgFilenames: string[] apkgFilenames: string[]
): Promise<string[]> { ): Promise<string[]> {
...@@ -52,26 +56,22 @@ async function linksToApkgs ( ...@@ -52,26 +56,22 @@ async function linksToApkgs (
return `### ${ return `### ${
basename(path, '.apkg').replace(/-/g, ' ').replace('fuer', 'für') basename(path, '.apkg').replace(/-/g, ' ').replace('fuer', 'für')
}\n${ }\n${
rawArtifactDownload(path) rawArtifactDownload(repo, path)
}` }`
}) })
} }
function rawArtifactDownload (path: string): string { function rawArtifactDownload (repo: string, path: string): string {
if (path === '') { if (path === '') {
throw new Error('path required') throw new Error('path required')
} }
return `https://gitlab.phaidra.org/kartenaale/sinologie-anki-pack/-/jobs/${ return `https://gitlab.phaidra.org/${
repo
}/-/jobs/${
getCiJobId() getCiJobId()
}/artifacts/raw/${encodeURIComponent(path)}` }/artifacts/raw/${encodeURIComponent(path)}`
} }
function allArtifactsZipDownload (): string {
return `https://gitlab.phaidra.org/kartenaale/sinologie-anki-pack/-/jobs/${
getCiJobId()
}/artifacts/download`
}
function getCiJobId (): string { function getCiJobId (): string {
return process.env.CI_JOB_ID ?? 'job-id-unavailable' return process.env.CI_JOB_ID ?? 'job-id-unavailable'
} }
...@@ -2,12 +2,19 @@ import { exit } from 'process' ...@@ -2,12 +2,19 @@ import { exit } from 'process'
import { announce } from './announce' import { announce } from './announce'
import { parseArgs } from 'util' import { parseArgs } from 'util'
const { values: { out, releaseDir, apkg } } = parseArgs({ const { values: { out, title, repo, releaseDir, apkg } } = parseArgs({
options: { options: {
out: { out: {
type: 'string', type: 'string',
short: 'o' short: 'o'
}, },
title: {
type: 'string'
},
repo: {
type: 'string',
short: 'r'
},
releaseDir: { releaseDir: {
type: 'string', type: 'string',
short: 'p' short: 'p'
...@@ -20,6 +27,8 @@ const { values: { out, releaseDir, apkg } } = parseArgs({ ...@@ -20,6 +27,8 @@ const { values: { out, releaseDir, apkg } } = parseArgs({
}) })
if (out === undefined || if (out === undefined ||
title === undefined ||
repo === undefined ||
releaseDir === undefined || releaseDir === undefined ||
apkg === undefined || apkg === undefined ||
apkg.length === 0) { apkg.length === 0) {
...@@ -27,7 +36,7 @@ if (out === undefined || ...@@ -27,7 +36,7 @@ if (out === undefined ||
throw new Error(`error: missing arguments, exiting.\nargs:${given}`) 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, undefined,
e => { e => {
console.error(e) console.error(e)
......
...@@ -8,8 +8,8 @@ announce: $(ANNOUNCEMENT_FILE) ...@@ -8,8 +8,8 @@ announce: $(ANNOUNCEMENT_FILE)
$(ANNOUNCEMENT_FILE): $(ANNOUNCE) $(PYTHON_NEEDED) build/export_apkgs.py $(ANNOUNCEMENT_FILE): $(ANNOUNCE) $(PYTHON_NEEDED) build/export_apkgs.py
$(ANNOUNCE) \ $(ANNOUNCE) \
--out $@ \ --out $@ \
--releaseDir $(RELEASE_DIR) \ --title '$(PACK_TITLE)' \
--repo $(GITLAB_REPO) \
--releaseDir $(DOWNLOAD_PREFIX)$(RELEASE_DIR) \
$(addprefix --apkg , \ $(addprefix --apkg , \
$(patsubst %,'%', \ $(patsubst %,'%',$(APKGS)))
$(shell PIPENV_VENV_IN_PROJECT=1 pipenv run \
build/export_apkgs.py --dry-run -c content -t no)))
CONTENT_DIR ?= content
APKG_TEST_DIR := test/build APKG_TEST_DIR := test/build
APKG_TEST_OK_FLAG := $(BUILD_PREFIX).apkg-test-ok 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') APKG_TEST_FILES := $(shell find $(APKG_TEST_DIR) -name '*.py' -o -name '*.yaml' -o -name '*.html' -o -name '*.csv')
......
...@@ -11,3 +11,14 @@ BUILD_PREFIX := $(and $(filter-out . ./,$(BUILD_PREFIX)),$(BUILD_PREFIX)/) ...@@ -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 # some build subprocesses need this, e.g. the JS proxy for parcel needs to
# know where to load the chardata from # know where to load the chardata from
export BUILD_PREFIX 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
# 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_DIR := $(BUILD_PREFIX)$(RELEASE_DIR_STEM)-$(VERSION)
RELEASE_ZIP := $(RELEASE_DIR).zip RELEASE_ZIP := $(RELEASE_DIR).zip
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment