Skip to content

Commit

Permalink
✨ Include commit hash in package when build
Browse files Browse the repository at this point in the history
* Display in `about` page
* Add to `issue template`
* Mac and linux only for now
  • Loading branch information
mingjun97 committed Feb 6, 2022
1 parent 7039e8d commit e469e2c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ package-lock.json
/youtube-music-desktop-app-*.tgz
app-update.yml
dev-app-update.yml
commit_hash.js
2 changes: 2 additions & 0 deletions commit_hash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
commit_hash = 'DEVELOPMENT_BUILD'
module.exports = { commit_hash: commit_hash }
2 changes: 2 additions & 0 deletions commit_hash.js.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
commit_hash = "DEVELOPMENT_BUILD";
module.exports = {commit_hash: commit_hash}
5 changes: 4 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const mprisProvider = (() => {
return null
}
})()

const { commit_hash } = require('./commit_hash')

/* Variables =========================================================================== */
const defaultUrl = 'https://music.youtube.com'

Expand Down Expand Up @@ -1673,7 +1676,7 @@ async function createWindow() {

const ytmdesktop_version = app.getVersion() || '-'

const template = `- [ ] I understand that %2A%2AYTMDesktop have NO affiliation with Google or YouTube%2A%2A.%0A- [ ] I verified that there is no open issue for the same subject.%0A%0A %2A%2ADescribe the bug%2A%2A%0A A clear and concise description of what the bug is.%0A%0A %2A%2ATo Reproduce%2A%2A%0A Steps to reproduce the behavior:%0A 1. Go to '...'%0A 2. Click on '....'%0A 3. See error%0A%0A %2A%2AExpected behavior%2A%2A%0A A clear and concise description of what you expected to happen.%0A%0A %2A%2AScreenshots%2A%2A%0A If applicable, add screenshots to help explain your problem.%0A%0A %2A%2AEnvironment:%2A%2A%0A %2A YTMDesktop version: %2A%2A%2Av${ytmdesktop_version}%2A%2A%2A%0A %2A OS: %2A%2A%2A${os_platform}%2A%2A%2A%0A %2A OS version: %2A%2A%2A${os_system_version}%2A%2A%2A%0A %2A Arch: %2A%2A%2A${os_arch}%2A%2A%2A%0A %2A Installation way: %2A%2A%2Alike .exe or snapcraft or another way%2A%2A%2A%0A`
const template = `- [ ] I understand that %2A%2AYTMDesktop have NO affiliation with Google or YouTube%2A%2A.%0A- [ ] I verified that there is no open issue for the same subject.%0A%0A %2A%2ADescribe the bug%2A%2A%0A A clear and concise description of what the bug is.%0A%0A %2A%2ATo Reproduce%2A%2A%0A Steps to reproduce the behavior:%0A 1. Go to '...'%0A 2. Click on '....'%0A 3. See error%0A%0A %2A%2AExpected behavior%2A%2A%0A A clear and concise description of what you expected to happen.%0A%0A %2A%2AScreenshots%2A%2A%0A If applicable, add screenshots to help explain your problem.%0A%0A %2A%2AEnvironment:%2A%2A%0A %2A YTMDesktop version: %2A%2A%2Av${ytmdesktop_version} ${commit_hash}%2A%2A%2A%0A %2A OS: %2A%2A%2A${os_platform}%2A%2A%2A%0A %2A OS version: %2A%2A%2A${os_system_version}%2A%2A%2A%0A %2A Arch: %2A%2A%2A${os_arch}%2A%2A%2A%0A %2A Installation way: %2A%2A%2Alike .exe or snapcraft or another way%2A%2A%2A%0A`
await shell.openExternal(
`https://github.com/ytmdesktop/ytmdesktop/issues/new?body=${template}`
)
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"rebuild": "electron-rebuild -f",
"postinstall": "npx electron-builder install-app-deps",
"build:win": "npx electron-builder --win --config electron-builder-deploy64.yml",
"build:mac": "npx electron-builder --mac --config electron-builder-deploy64.yml",
"build:lin": "npx electron-builder --linux --config electron-builder-deploy64.yml",
"build:mac": "command -v git > /dev/null 2>&1 && sed -e \"s/DEVELOPMENT_BUILD/`git rev-parse HEAD | cut -c1-8`/g\" commit_hash.js.tpl >commit_hash.js; npx electron-builder --mac --config electron-builder-deploy64.yml",
"build:lin": "command -v git > /dev/null 2>&1 && sed -e \"s/DEVELOPMENT_BUILD/`git rev-parse HEAD | cut -c1-8`/g\" commit_hash.js.tpl >commit_hash.js; npx electron-builder --linux --config electron-builder-deploy64.yml",
"publish:win": "npx electron-builder --win -p always --config electron-builder64.yml",
"publish:mac": "npx electron-builder --mac -p always --config electron-builder64.yml",
"publish:lin": "npx electron-builder --linux -p always --config electron-builder64.yml"
"publish:mac": "command -v git > /dev/null 2>&1 && sed -e \"s/DEVELOPMENT_BUILD/`git rev-parse HEAD | cut -c1-8`/g\" commit_hash.js.tpl >commit_hash.js; npx electron-builder --mac -p always --config electron-builder64.yml",
"publish:lin": "command -v git > /dev/null 2>&1 && sed -e \"s/DEVELOPMENT_BUILD/`git rev-parse HEAD | cut -c1-8`/g\" commit_hash.js.tpl >commit_hash.js; npx electron-builder --linux -p always --config electron-builder64.yml"
},
"repository": "https://github.com/ytmdesktop/ytmdesktop",
"keywords": [
Expand Down
9 changes: 8 additions & 1 deletion src/pages/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
href="../../../src/assets/css/styles.css"
/>
<link type="text/css" rel="stylesheet" href="./settings.css" />
<script type="text/javascript" src="../../../commit_hash.js"></script>
</head>
<body>
<div id="content" class="hide">
Expand Down Expand Up @@ -1389,7 +1390,10 @@
>
<div class="row">
<span style="color: #aaa">
v<span id="app-version"></span> <br /><br />
v<span id="app-version"></span> <br /><span
>Commit hash:
<span id="app-hash"></span></span
><br /><br />
<button
id="release-notes"
class="btn waves-effect waves-light red"
Expand Down Expand Up @@ -1464,5 +1468,8 @@
<script>
require('./settings.js')
</script>
<script>
document.getElementById('app-hash').innerText = commit_hash
</script>
</body>
</html>

0 comments on commit e469e2c

Please sign in to comment.