Skip to content

Commit

Permalink
remove git dependency from the build process
Browse files Browse the repository at this point in the history
Depending on the git to check version number during
build time proved to be a headache, so we have returend
to using the version from `package.json` file.

The idea is good though, probably should be placed into
the CI pipe as a step so the build itself does not depend
on the git tag.

(It caused issues with the firefox release and also internally)
  • Loading branch information
Gergo Nagy committed Mar 16, 2022
1 parent c769dd9 commit a568aa9
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 46 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"@tallyho/tally-ui": "0.0.1",
"@tallyho/window-provider": "0.0.1",
"buffer": "^6.0.3",
"git-revision-webpack-plugin": "^5.0.0",
"react": "^17.0.2",
"webext-options-sync": "^2.0.1",
"webextension-polyfill": "^0.7.0"
Expand Down
6 changes: 1 addition & 5 deletions ui/pages/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,7 @@ export default function Menu(): ReactElement {
Give feedback!
</SharedButton>
<div className="version">
Version: {process.env.VERSION ?? `<unknown>`} (
{new Date(
process.env.GIT_COMMIT_DATE ?? "invalid date"
).toLocaleDateString(undefined, { dateStyle: "medium" })}
)
Version: {process.env.VERSION ?? `<unknown>`}
</div>
</div>
</section>
Expand Down
36 changes: 1 addition & 35 deletions webpack.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import path from "path"
import webpack, {
Configuration,
Expand All @@ -13,29 +12,10 @@ import TerserPlugin from "terser-webpack-plugin"
import LiveReloadPlugin from "webpack-livereload-plugin"
import CopyPlugin, { ObjectPattern } from "copy-webpack-plugin"
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin"
import { GitRevisionPlugin } from "git-revision-webpack-plugin"
import WebExtensionArchivePlugin from "./build-utils/web-extension-archive-webpack-plugin"

const supportedBrowsers = ["brave", "chrome", "edge", "firefox", "opera"]

const gitRevisionPlugin = new GitRevisionPlugin({
/* `--tags` option allows for un-annotated tags, currently present in the repo */
versionCommand: `describe --tags`,
})

const gitVersion = gitRevisionPlugin.version()
if (gitVersion === null || !gitVersion.startsWith("v")) {
throw new Error(`cannot get current version from git: missing or invalid`)
}

const [manifestVersion, versionQualifier] = gitVersion
.substring(1)
.split("-", 2)

if (typeof versionQualifier !== "undefined") {
console.log(`Building NON-OFFICIAL version ${gitVersion}. Do not release.`)
}

// Replicated and adjusted for each target browser and the current build mode.
const baseConfig: Configuration = {
devtool: "source-map",
Expand Down Expand Up @@ -112,16 +92,8 @@ const baseConfig: Configuration = {
// FIXME version refed in @types/copy-webpack-plugin and our local
// FIXME webpack version.
}) as unknown as WebpackPluginInstance,
gitRevisionPlugin,
new DefinePlugin({
"process.env.GIT_COMMIT_HASH": JSON.stringify(
gitRevisionPlugin.commithash()
),
"process.env.GIT_COMMIT_DATE": JSON.stringify(
gitRevisionPlugin.lastcommitdatetime()
),
"process.env.GIT_BRANCH": JSON.stringify(gitRevisionPlugin.branch()),
"process.env.VERSION": JSON.stringify(gitRevisionPlugin.version()),
"process.env.VERSION": JSON.stringify(process.env.npm_package_version),
}),
],
optimization: {
Expand Down Expand Up @@ -235,12 +207,6 @@ export default (
.map((assetData) => JSON.parse(assetData))
)

if (combinedManifest.version !== manifestVersion) {
throw new Error(
`manifest version '${combinedManifest.version}' does not match git version '${manifestVersion}'`
)
}

return JSON.stringify(combinedManifest, null, 2)
},
} as unknown as ObjectPattern, // ObjectPattern doesn't include transformAll in current types
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6061,11 +6061,6 @@ getport@^0.1.0:
resolved "https://registry.yarnpkg.com/getport/-/getport-0.1.0.tgz#abddf3d5d1e77dd967ccfa2b036a0a1fb26fd7f7"
integrity sha1-q93z1dHnfdlnzPorA2oKH7Jv1/c=

git-revision-webpack-plugin@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/git-revision-webpack-plugin/-/git-revision-webpack-plugin-5.0.0.tgz#0683a6a110ece618499880431cd89e1eb597b536"
integrity sha512-RptQN/4UKcEPkCBmRy8kLPo5i8MnF8+XfAgFYN9gbwmKLTLx4YHsQw726H+C5+sIGDixDkmGL3IxPA2gKo+u4w==

glob-parent@^5.1.2, glob-parent@~5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
Expand Down

0 comments on commit a568aa9

Please sign in to comment.