Skip to content

Commit fc2cfe6

Browse files
committed
fixes? + version,js in deploy action
1 parent c1c82fe commit fc2cfe6

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,30 @@ jobs:
2525
exit 1
2626
fi
2727
28+
- name: Generate version.js
29+
run: |
30+
mkdir -p dist
31+
COMMIT_ID=$(git rev-parse HEAD | cut -c1-7)
32+
YEAR=$(date +%Y)
33+
VERSION=$(jq -r .version package.json)
34+
TAG=$(jq -r .version_tag package.json)
35+
36+
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
37+
SUFFIX="prod"
38+
else
39+
SUFFIX="dev"
40+
fi
41+
42+
if [ "$TAG" != "null" ]; then
43+
FULL_VERSION="${YEAR}.${VERSION}-${TAG}-${SUFFIX}"
44+
else
45+
FULL_VERSION="${YEAR}.${VERSION}-${SUFFIX}"
46+
fi
47+
48+
echo "const version = \"$FULL_VERSION\"; const commit_id = \"$COMMIT_ID\"; module.exports = { version, commit_id };" > src/version.js
49+
50+
51+
2852
# 1️⃣ Checkout your code
2953
- name: Checkout repository
3054
uses: actions/checkout@v4

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"description": "A Discord music bot that features Last.fm and Discogs integration.",
66
"main": "index.js",
77
"scripts": {
8-
"build": "tsc --diagnostics && node scripts/version.js",
8+
"build": "tsc --diagnostics",
99
"prestart": "tsc --diagnostics && node scripts/version.js",
1010
"start": "node build/index.js",
11-
"start:dev": "npm run start",
11+
"start:dev": "node scripts/version.js && npm run start",
1212
"postversion": "node scripts/version.js",
1313
"test": "echo \"Error: no test specified\" && exit 1"
1414
},

0 commit comments

Comments
 (0)