Skip to content

Commit dfc40d2

Browse files
Change package name
1 parent 42119e2 commit dfc40d2

File tree

4 files changed

+131
-83
lines changed

4 files changed

+131
-83
lines changed

.github/workflows/release.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ jobs:
6262
- name: Package zip
6363
# if: startsWith(github.ref, 'refs/tags/')
6464
run: |
65-
make package ARCH=${{ matrix.platform.release_for }} TARGET=${{ matrix.platform.target }} TAG=${{ env.TAG_NAME }}
65+
make package PLATFORM=${{ matrix.platform.release_for }} TARGET=${{ matrix.platform.target }}
6666
6767
- name: Release
6868
uses: softprops/action-gh-release@v2
6969
# if: startsWith(github.ref, 'refs/tags/')
7070
with:
71-
body: '[Changelog](https://github.com/containerscrew/gitrack/blob/main/CHANGELOG.md)'
71+
# body: '[Changelog](https://github.com/containerscrew/gitrack/blob/main/CHANGELOG.md)'
7272
files: |
7373
CHANGELOG.md
7474
LICENSE
@@ -77,3 +77,15 @@ jobs:
7777
token: ${{ secrets.RELEASE_TOKEN }}
7878
generate_release_notes: true
7979
append_body: true
80+
81+
- name: Update CHANGELOG.md in main branch
82+
# if: github.ref == 'refs/tags/v*.*.*'
83+
run: |
84+
git config --global user.name 'containerscrew'
85+
git config --global user.email '[email protected]'
86+
git checkout main
87+
git pull origin main
88+
make generate-changelog
89+
git add CHANGELOG.md
90+
git commit -m "Update CHANGELOG.md for release ${{ env.TAG_NAME }}"
91+
git push origin main

CHANGELOG.md

Lines changed: 0 additions & 80 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pre-commit: ## Run pre-commit
1111
pre-commit run -a
1212

1313
package: ## Package binary with zip
14-
zip -j ${BINARY_NAME}-$(ARCH)-$(TAG).zip target/$(TARGET)/release/${BINARY_NAME}
14+
zip -j ${BINARY_NAME}-$(PLATFORM).zip target/$(TARGET)/release/${BINARY_NAME}
1515

1616
generate-changelog: ## Generate changelog using git cliff
1717
git cliff --output CHANGELOG.md

install.sh

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# Global vars
6+
INSTALLATION_PATH="/usr/local/bin/"
7+
8+
happyexit(){
9+
echo ""
10+
echo "gitrack successfully installed! 🎉"
11+
echo ""
12+
echo "Now run: $ gitrack usage"
13+
echo ""
14+
exit 0
15+
}
16+
17+
# Check OS
18+
OS=$(uname -s)
19+
arch=$(uname -m)
20+
cli_arch=""
21+
case $OS in
22+
Darwin)
23+
case $arch in
24+
x86_64)
25+
cli_arch=amd64
26+
;;
27+
arm64)
28+
cli_arch=$arch
29+
;;
30+
*)
31+
echo "There is no gitrack $OS support for $arch"
32+
exit 1
33+
;;
34+
esac
35+
;;
36+
Linux)
37+
case $arch in
38+
x86_64)
39+
cli_arch=amd64
40+
;;
41+
armv8*)
42+
cli_arch=arm64
43+
;;
44+
aarch64*)
45+
cli_arch=arm64
46+
;;
47+
amd64|arm64)
48+
cli_arch=$arch
49+
;;
50+
*)
51+
echo "There is no gitrack $OS support for $arch"
52+
exit 1
53+
;;
54+
esac
55+
;;
56+
*)
57+
echo "There is no gitrack $OS support for $arch"
58+
exit 1
59+
;;
60+
esac
61+
OS=$(echo "$OS" | tr '[:upper:]' '[:lower:]')
62+
63+
download_release() {
64+
LATEST_VERSION=$(curl -s https://api.github.com/repos/containerscrew/gitrack/releases/latest | jq -r ".name")
65+
if [ -z "$1" ]; then VERSION=$LATEST_VERSION; else VERSION=$1; fi
66+
67+
printf "\033[0;32m[info] - Downloading version: ${VERSION}/tftools-${OS}-${cli_arch}.tar.gz \033[0m\n"
68+
curl -L --fail --remote-name-all https://github.com/containerscrew/tftools/releases/download/"${VERSION}"/tftools-"${OS}"-"${cli_arch}".tar.gz -o /tmp/tftools.tar.gz
69+
tar -xzf /tmp/tftools.tar.gz -C /tmp/
70+
}
71+
72+
install_binary(){
73+
if [ "$(id -u)" = 0 ]; then
74+
cp /tmp/tftools $INSTALLATION_PATH
75+
chmod +x $INSTALLATION_PATH/tftools
76+
else
77+
sudo cp /tmp/tftools $INSTALLATION_PATH
78+
sudo chmod +x $INSTALLATION_PATH/tftools
79+
fi
80+
rm -rf /tmp/tftools*
81+
happyexit
82+
}
83+
84+
# Function to display help text
85+
usage() {
86+
echo "Usage: $0 [-v] [-h]"
87+
echo "Options:"
88+
echo " -v Select which version do you want to install."
89+
echo " -h Display the help message"
90+
}
91+
92+
# Parse options using getopts
93+
while getopts "v:h" option; do
94+
case "${option}" in
95+
v) # Install specific version
96+
version=${OPTARG}
97+
download_release "$version"
98+
install_binary
99+
;;
100+
h) # Help option
101+
usage
102+
exit 0
103+
;;
104+
\?) # Invalid option
105+
echo "Invalid option: -${OPTARG}"
106+
usage
107+
exit 1
108+
;;
109+
esac
110+
done
111+
112+
# If no flags, by default install latest version
113+
if [ $# -eq 0 ]; then
114+
download_release
115+
install_binary
116+
fi

0 commit comments

Comments
 (0)