Skip to content

Commit 1d6926b

Browse files
committed
fix: Fixes task release to pull tags before releasing
1 parent 4538aa2 commit 1d6926b

File tree

4 files changed

+94
-21
lines changed

4 files changed

+94
-21
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ jobs:
2929
version: latest
3030
args: release --clean
3131
env:
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
3333

3434
- name: Update Homebrew tap
3535
if: success()
3636
uses: dawidd6/action-homebrew-bump-formula@v3
3737
with:
38-
token: ${{ secrets.GITHUB_TOKEN }}
38+
token: ${{ secrets.GH_PAT }}
3939
tap: scalvert/homebrew-tap
4040
formula: glean-cli
4141
tag: ${{ github.ref_name }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
./glean
1+
glean

install.sh

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,57 @@ trap cleanup EXIT
3131

3232
# Download and extract
3333
echo "Downloading Glean CLI ${LATEST_VERSION}..."
34+
echo "Download URL: $DOWNLOAD_URL"
3435
curl -fsSL "$DOWNLOAD_URL" -o "$TMP_DIR/glean.tar.gz"
36+
37+
echo "Extracting archive..."
38+
tar -tvf "$TMP_DIR/glean.tar.gz"
3539
tar -xzf "$TMP_DIR/glean.tar.gz" -C "$TMP_DIR"
3640

41+
echo "Verifying extracted contents..."
42+
ls -la "$TMP_DIR"
43+
3744
# Install binary
3845
INSTALL_DIR="/usr/local/bin"
39-
if [ ! -w "$INSTALL_DIR" ]; then
40-
echo "Installing Glean CLI requires sudo access to $INSTALL_DIR"
41-
sudo mv "$TMP_DIR/glean" "$INSTALL_DIR/"
42-
sudo chmod +x "$INSTALL_DIR/glean"
43-
else
44-
mv "$TMP_DIR/glean" "$INSTALL_DIR/"
46+
47+
# Create install directory if it doesn't exist
48+
if [ ! -d "$INSTALL_DIR" ]; then
49+
echo "Creating $INSTALL_DIR directory..."
50+
if ! sudo mkdir -p "$INSTALL_DIR"; then
51+
echo "Failed to create $INSTALL_DIR"
52+
exit 1
53+
fi
54+
fi
55+
56+
# Set proper ownership for /usr/local/bin if it was just created
57+
if [ -d "$INSTALL_DIR" ]; then
58+
sudo chown -R $(whoami) "$INSTALL_DIR" 2>/dev/null || true
59+
fi
60+
61+
# Find the glean binary
62+
GLEAN_BINARY=$(find "$TMP_DIR" -type f -name "glean" -o -name "glean.exe" | head -n 1)
63+
64+
if [ -z "$GLEAN_BINARY" ]; then
65+
echo "Error: Could not find glean binary in extracted files"
66+
echo "Contents of temp directory:"
67+
ls -R "$TMP_DIR"
68+
exit 1
69+
fi
70+
71+
# Attempt installation
72+
echo "Installing to $INSTALL_DIR..."
73+
echo "Installing $GLEAN_BINARY to $INSTALL_DIR/glean"
74+
75+
if [ -w "$INSTALL_DIR" ]; then
76+
# We have write permission
77+
mv "$GLEAN_BINARY" "$INSTALL_DIR/glean"
4578
chmod +x "$INSTALL_DIR/glean"
79+
else
80+
# We need sudo
81+
echo "Elevated permissions required for installation..."
82+
sudo mv "$GLEAN_BINARY" "$INSTALL_DIR/glean"
83+
sudo chmod +x "$INSTALL_DIR/glean"
4684
fi
4785

48-
echo "Glean CLI has been installed to $INSTALL_DIR/glean"
86+
echo "Glean CLI ${LATEST_VERSION} has been installed to $INSTALL_DIR/glean"
4987
echo "Run 'glean --help' to get started"

taskfile.yml

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,63 @@ tasks:
4343

4444
release:
4545
desc: Create and push a new release
46+
vars:
47+
VERSION: '{{.VERSION | default ""}}'
48+
FORCE: '{{.FORCE | default "false"}}'
4649
cmds:
4750
# Ensure we're on main and up to date
4851
- git checkout main
4952
- git pull origin main
53+
- git fetch --tags
5054

5155
# Run checks
5256
- task: check
5357

54-
# Get the next version
55-
- echo "Next version will be $(svu next)"
56-
- echo "Press Ctrl+C to cancel or wait 5 seconds to continue..."
57-
- sleep 5
58+
# Show current version and commits since last release
59+
- echo "Current version is $(svu current)"
60+
- echo "Commits since last release:"
61+
- git log $(svu current)..HEAD --oneline
5862

59-
# Create and push the tag
63+
# Get and validate the version, create and push tag
6064
- |
61-
version=$(svu next)
62-
git tag -a $version -m "Release $version"
63-
git push origin $version
65+
# Set version
66+
if [ -n "{{.VERSION}}" ]; then
67+
version="{{.VERSION}}"
68+
# Validate version format (vX.Y.Z where X,Y,Z are numbers)
69+
if ! echo "$version" | grep -qE "^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$"; then
70+
echo "Error: Version must be in format vX.Y.Z where X,Y,Z are numbers (e.g. v1.2.3)"
71+
exit 1
72+
fi
73+
echo "Using specified version: $version"
74+
else
75+
version=$(svu next)
76+
echo "Next version will be $version"
77+
fi
6478
65-
# Instructions for monitoring
66-
- echo "Release process started!"
67-
- echo "Monitor the release at https://github.com/scalvert/glean-cli/actions"
79+
# Confirm before proceeding
80+
echo "Press Ctrl+C to cancel or wait 5 seconds to continue..."
81+
sleep 5
82+
83+
# Handle existing tag if force is true
84+
if [ "{{.FORCE}}" = "true" ]; then
85+
if git rev-parse "$version" >/dev/null 2>&1; then
86+
echo "Force flag set. Removing existing tag $version"
87+
git tag -d "$version"
88+
git push origin ":refs/tags/$version"
89+
fi
90+
fi
91+
92+
# Create and push the tag
93+
if [ "{{.FORCE}}" = "true" ]; then
94+
git tag -f -a "$version" -m "Release $version"
95+
else
96+
git tag -a "$version" -m "Release $version"
97+
fi
98+
git push origin "$version" --force
99+
100+
# Instructions for monitoring
101+
echo "Release process started!"
102+
echo "Monitor the release at https://github.com/scalvert/glean-cli/actions"
68103
preconditions:
69104
- sh: "git diff-index --quiet HEAD"
70105
msg: "Working directory is not clean. Please commit or stash changes first."

0 commit comments

Comments
 (0)