Skip to content

Commit eb39494

Browse files
committed
meta: add release script
1 parent b39adae commit eb39494

File tree

3 files changed

+78
-9
lines changed

3 files changed

+78
-9
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# .gitignore
2+
# Tells Git to ignore some files and folders
3+
4+
build/
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
"Description": "Format your code using Prettier",
55
"Website": "https://github.com/gamemaker1/micro-plugin-prettier",
66
"Tags": ["javascript", "node", "nodejs", "typescript", "formatting"],
7-
"Versions": [
8-
{
9-
"Version": "0.1.0",
10-
"Url": "https://github.com/gamemaker1/micro-plugin-prettier/releases/latest/download/prettier-0.1.0.zip",
11-
"Require": {
12-
"micro": ">=1.0.3"
13-
}
14-
}
15-
]
7+
"Versions": []
168
}
179
]

scripts/release

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
# release
4+
# A script to create a new release for this plugin
5+
6+
# Requires the following to be installed:
7+
# - `git`: Git CLI
8+
# - `gh`: Github CLI
9+
# - `jq`: Command line JSON manipulation
10+
# - `zip`: ZIP file creation
11+
# - `npx`: Run an NPM package
12+
13+
# The new version must be passed as the first argument
14+
if [[ -z "$1" ]]; then
15+
echo "[error] Please pass the new version as the first argument"
16+
exit 1
17+
fi
18+
19+
version="$1"
20+
21+
# Ensure that there are no unstaged changes
22+
if ! [[ -z "$(git status --porcelain)" ]]; then
23+
echo "[error] Please commit all changes before creating a new release"
24+
exit 1
25+
fi
26+
27+
# Change the version in `source/prettier.lua`
28+
sed -i "s/^VERSION = .*/VERSION = $version/" source/prettier.lua
29+
30+
# Add a new entry to `assets/metadata.json`
31+
meta=`cat assets/metadata.json | jq ".[0].Versions += [
32+
{
33+
\"Version\": \"$version\",
34+
\"Url\": \"https://github.com/gamemaker1/micro-plugin-prettier/releases/$version/download/prettier.zip\",
35+
\"Require\": { \"micro\": \">=1.0.3\" }
36+
}
37+
]"`
38+
echo $meta > assets/metadata.json
39+
npx prettier --write assets/metadata.json
40+
41+
echo "[info] Updated version"
42+
43+
# Commit the changes
44+
git add .
45+
git commit -m "chore(release): $version"
46+
# Tag the commit
47+
git tag $version
48+
49+
echo "[info] Created and tagged commit"
50+
51+
# Push the commit and tag to GitHub
52+
git push -f origin main
53+
git push -f origin $version
54+
55+
echo "[info] Pushed to Github"
56+
57+
# Create a zip file with files needed by Micro
58+
rm -rf build/
59+
mkdir -p build/ && cd build/
60+
cp ../assets/metadata.json ./repo.json
61+
cp ../source/prettier.lua ./prettier.lua
62+
zip -qr9 prettier.zip ./repo.json ./prettier.lua
63+
cd ..
64+
65+
echo "[info] Created distributable zip"
66+
67+
# Create a Github Release with the created file
68+
gh release create $version ./build/prettier.zip
69+
70+
echo "[info] Created a new release ($version)!"
71+
72+
# Open the release in the browser so we can add the change notes
73+
gh release view -w $version

0 commit comments

Comments
 (0)