Skip to content

Commit

Permalink
Remove hardcoded version from manifest
Browse files Browse the repository at this point in the history
* Dynamically set version as argument to build script
* Set version using tag ref_name in CI
* [Cleanup] gitignore ext/manifest.json as it's dynamically generated
  • Loading branch information
djahandarie committed Sep 23, 2023
1 parent 94ccff4 commit 2d8f6be
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/create-prerelease-on-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
node-version-file: ".node-version"

- name: Lint
run: npm run-script build
run: npm run-script build -- --yomitan-version ${{ github.ref_name }}
shell: bash

- name: Release
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dictionaries/
/playwright-report/
/playwright/.cache/
/test/playwright/__screenshots__/
ext/manifest.json
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Several command line arguments are available for these scripts:
* `--manifest <target>` - Overwrites [ext/manifest.json](ext/manifest.json) with the manifest variant for the specified build target.
* `--dry-run` - Runs the full build process (excluding zip building), checking that the configuration is valid.
* `--dry-run-build-zip` - If `--dry-run` is also specified, zip building will also be performed in memory; no files are created.
* `--yomitan-version <version>` - Sets the version number in the extension manifest. Defaults to 0.0.0.0 if not set.

If no arguments are specified, the command is equivalent to `build.bat --all`.

Expand Down
12 changes: 8 additions & 4 deletions dev/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function getIndexOfFilePath(array, item) {
return -1;
}

async function build(buildDir, extDir, manifestUtil, variantNames, manifestPath, dryRun, dryRunBuildZip) {
async function build(buildDir, extDir, manifestUtil, variantNames, manifestPath, dryRun, dryRunBuildZip, yomitanVersion) {
const sevenZipExes = ['7za', '7z'];

// Create build directory
Expand All @@ -130,6 +130,8 @@ async function build(buildDir, extDir, manifestUtil, variantNames, manifestPath,
process.stdout.write(message);
};

process.stdout.write(`Version: ${yomitanVersion}...\n`);

for (const variantName of variantNames) {
const variant = manifestUtil.getVariant(variantName);
if (typeof variant === 'undefined' || variant.buildable === false) { continue; }
Expand All @@ -148,7 +150,7 @@ async function build(buildDir, extDir, manifestUtil, variantNames, manifestPath,
const fileNameSafe = path.basename(fileName);
const fullFileName = path.join(buildDir, fileNameSafe);
if (!dryRun) {
fs.writeFileSync(manifestPath, ManifestUtil.createManifestString(modifiedManifest));
fs.writeFileSync(manifestPath, ManifestUtil.createManifestString(modifiedManifest).replace('$YOMITAN_VERSION', yomitanVersion));
}

if (!dryRun || dryRunBuildZip) {
Expand Down Expand Up @@ -183,11 +185,13 @@ async function main(argv) {
['manifest', null],
['dry-run', false],
['dry-run-build-zip', false],
['yomitan-version', '0.0.0.0'],
[null, []]
]));

const dryRun = args.get('dry-run');
const dryRunBuildZip = args.get('dry-run-build-zip');
const yomitanVersion = args.get('yomitan-version');

const manifestUtil = new ManifestUtil();

Expand All @@ -202,14 +206,14 @@ async function main(argv) {
manifestUtil.getVariants().filter(({buildable}) => buildable !== false).map(({name}) => name) :
args.get(null)
);
await build(buildDir, extDir, manifestUtil, variantNames, manifestPath, dryRun, dryRunBuildZip);
await build(buildDir, extDir, manifestUtil, variantNames, manifestPath, dryRun, dryRunBuildZip, yomitanVersion);
} finally {
// Restore manifest
const manifestName = (!args.get('default') && args.get('manifest') !== null) ? args.get('manifest') : null;
const restoreManifest = manifestUtil.getManifest(manifestName);
process.stdout.write('Restoring manifest...\n');
if (!dryRun) {
fs.writeFileSync(manifestPath, ManifestUtil.createManifestString(restoreManifest));
fs.writeFileSync(manifestPath, ManifestUtil.createManifestString(restoreManifest).replace('$YOMITAN_VERSION', yomitanVersion));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion dev/data/manifest-variants.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest": {
"manifest_version": 3,
"name": "Yomitan",
"version": "23.4.7.0",
"version": "$YOMITAN_VERSION",
"description": "Japanese dictionary with Anki integration",
"author": "TheMoeWay",
"icons": {
Expand Down
131 changes: 0 additions & 131 deletions ext/manifest.json

This file was deleted.

0 comments on commit 2d8f6be

Please sign in to comment.