ci: update github-actions

This commit is contained in:
Rene Leonhardt
2025-07-28 09:10:51 +02:00
parent 4b11563bdf
commit 150e8adf8b
3 changed files with 49 additions and 29 deletions

17
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/optimizing-pr-creation-version-updates#setting-up-a-cooldown-period-for-dependency-updates
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/dependabot-options-reference#groups--
groups:
actions:
# Combine all images of last week
patterns: ["*"]
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly

View File

@@ -9,6 +9,9 @@ on:
permissions:
contents: read
env:
GO_VERSION: '1.24'
jobs:
test:
runs-on: ubuntu-latest
@@ -19,10 +22,10 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
go-version: ${{ env.GO_VERSION }}
- name: Cache Go modules
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
@@ -44,9 +47,9 @@ jobs:
run: go test -v -race -coverprofile=coverage.out ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
file: ./coverage.out
files: ./coverage.out
lint:
runs-on: ubuntu-latest
@@ -57,10 +60,10 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
go-version: ${{ env.GO_VERSION }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v8
with:
version: latest
@@ -74,7 +77,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
go-version: ${{ env.GO_VERSION }}
- name: Build
run: go build -v ./...
@@ -84,4 +87,4 @@ jobs:
with:
distribution: goreleaser
version: latest
args: build --snapshot --clean
args: build --snapshot --clean

View File

@@ -18,7 +18,7 @@ INSTALL_DIR="/usr/local/bin"
BINARY_NAME="lnk"
# Fallback version if redirect fails
FALLBACK_VERSION="v0.0.2"
FALLBACK_VERSION="v0.3.0"
# Detect OS and architecture
detect_platform() {
@@ -51,28 +51,28 @@ detect_platform() {
# Get latest version by following redirect
get_latest_version() {
echo -e "${BLUE}Getting latest release version...${NC}" >&2
# Get redirect location from releases/latest
local redirect_url
redirect_url=$(curl -s -I "https://github.com/${REPO}/releases/latest" | grep -i "^location:" | sed 's/\r$//' | cut -d' ' -f2-)
if [ -z "$redirect_url" ]; then
echo -e "${YELLOW}⚠ Could not get redirect URL, using fallback version ${FALLBACK_VERSION}${NC}" >&2
echo "$FALLBACK_VERSION"
return 0
fi
# Extract version from redirect URL (format: https://github.com/user/repo/releases/tag/v1.2.3)
local version
version=$(echo "$redirect_url" | sed -E 's|.*/releases/tag/([^/]*)\s*$|\1|')
if [ -z "$version" ] || [ "$version" = "$redirect_url" ]; then
echo -e "${YELLOW}⚠ Could not parse version from redirect URL: $redirect_url${NC}" >&2
echo -e "${YELLOW}Using fallback version ${FALLBACK_VERSION}${NC}" >&2
echo "$FALLBACK_VERSION"
return 0
fi
echo "$version"
}
@@ -91,25 +91,25 @@ get_version() {
# Download and install
install_lnk() {
local platform version
echo -e "${BLUE}🔗 Installing lnk...${NC}"
platform=$(detect_platform)
version=$(get_version "$1")
echo -e "${BLUE}Version: ${version}${NC}"
echo -e "${BLUE}Platform: ${platform}${NC}"
# Download URL
local filename="lnk_${platform}.tar.gz"
local url="https://github.com/${REPO}/releases/download/${version}/${filename}"
echo -e "${BLUE}Downloading ${url}...${NC}"
# Create temporary directory
local tmp_dir=$(mktemp -d)
cd "$tmp_dir"
# Download the binary
if ! curl -sL "$url" -o "$filename"; then
echo -e "${RED}Error: Failed to download ${url}${NC}"
@@ -117,7 +117,7 @@ install_lnk() {
echo -e "${YELLOW}Available releases: https://github.com/${REPO}/releases${NC}"
exit 1
fi
# Check if we got an HTML error page instead of the binary
if file "$filename" 2>/dev/null | grep -q "HTML"; then
echo -e "${RED}Error: Downloaded file appears to be an HTML page (404 error)${NC}"
@@ -125,30 +125,30 @@ install_lnk() {
echo -e "${YELLOW}Available releases: https://github.com/${REPO}/releases${NC}"
exit 1
fi
# Extract the binary
if ! tar -xzf "$filename"; then
echo -e "${RED}Error: Failed to extract ${filename}${NC}"
exit 1
fi
# Make binary executable
chmod +x "$BINARY_NAME"
# Install to system directory
echo -e "${YELLOW}Installing to ${INSTALL_DIR} (requires sudo)...${NC}"
if ! sudo mv "$BINARY_NAME" "$INSTALL_DIR/"; then
echo -e "${RED}Error: Failed to install binary${NC}"
exit 1
fi
# Cleanup
cd - > /dev/null
rm -rf "$tmp_dir"
echo -e "${GREEN}✅ lnk installed successfully!${NC}"
echo -e "${GREEN}Run 'lnk --help' to get started.${NC}"
# Test the installation
if command -v lnk >/dev/null 2>&1; then
echo -e "${GREEN}Installed version: $(lnk --version)${NC}"
@@ -177,4 +177,4 @@ if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
fi
# Run the installer
install_lnk "$1"
install_lnk "$1"