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

chore: more announcement customization

parent af48aa15
Branches
No related tags found
1 merge request!134chore: more announcement customization
Pipeline #13769 passed
......@@ -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'
}
......@@ -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)
......
......@@ -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)))
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')
......
......@@ -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
# 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment