mirror of
https://github.com/yarlson/lnk.git
synced 2025-09-02 18:12:33 +02:00
ci: update github-actions
This commit is contained in:
17
.github/dependabot.yml
vendored
Normal file
17
.github/dependabot.yml
vendored
Normal 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
|
19
.github/workflows/ci.yml
vendored
19
.github/workflows/ci.yml
vendored
@@ -9,6 +9,9 @@ on:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
|
env:
|
||||||
|
GO_VERSION: '1.24'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -19,10 +22,10 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.24'
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
- name: Cache Go modules
|
- name: Cache Go modules
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/go/pkg/mod
|
path: ~/go/pkg/mod
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
@@ -44,9 +47,9 @@ jobs:
|
|||||||
run: go test -v -race -coverprofile=coverage.out ./...
|
run: go test -v -race -coverprofile=coverage.out ./...
|
||||||
|
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v5
|
||||||
with:
|
with:
|
||||||
file: ./coverage.out
|
files: ./coverage.out
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -57,10 +60,10 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.24'
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v3
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
|
|
||||||
@@ -74,7 +77,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.24'
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: go build -v ./...
|
run: go build -v ./...
|
||||||
@@ -84,4 +87,4 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
distribution: goreleaser
|
distribution: goreleaser
|
||||||
version: latest
|
version: latest
|
||||||
args: build --snapshot --clean
|
args: build --snapshot --clean
|
||||||
|
42
install.sh
42
install.sh
@@ -18,7 +18,7 @@ INSTALL_DIR="/usr/local/bin"
|
|||||||
BINARY_NAME="lnk"
|
BINARY_NAME="lnk"
|
||||||
|
|
||||||
# Fallback version if redirect fails
|
# Fallback version if redirect fails
|
||||||
FALLBACK_VERSION="v0.0.2"
|
FALLBACK_VERSION="v0.3.0"
|
||||||
|
|
||||||
# Detect OS and architecture
|
# Detect OS and architecture
|
||||||
detect_platform() {
|
detect_platform() {
|
||||||
@@ -51,28 +51,28 @@ detect_platform() {
|
|||||||
# Get latest version by following redirect
|
# Get latest version by following redirect
|
||||||
get_latest_version() {
|
get_latest_version() {
|
||||||
echo -e "${BLUE}Getting latest release version...${NC}" >&2
|
echo -e "${BLUE}Getting latest release version...${NC}" >&2
|
||||||
|
|
||||||
# Get redirect location from releases/latest
|
# Get redirect location from releases/latest
|
||||||
local redirect_url
|
local redirect_url
|
||||||
redirect_url=$(curl -s -I "https://github.com/${REPO}/releases/latest" | grep -i "^location:" | sed 's/\r$//' | cut -d' ' -f2-)
|
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
|
if [ -z "$redirect_url" ]; then
|
||||||
echo -e "${YELLOW}⚠ Could not get redirect URL, using fallback version ${FALLBACK_VERSION}${NC}" >&2
|
echo -e "${YELLOW}⚠ Could not get redirect URL, using fallback version ${FALLBACK_VERSION}${NC}" >&2
|
||||||
echo "$FALLBACK_VERSION"
|
echo "$FALLBACK_VERSION"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract version from redirect URL (format: https://github.com/user/repo/releases/tag/v1.2.3)
|
# Extract version from redirect URL (format: https://github.com/user/repo/releases/tag/v1.2.3)
|
||||||
local version
|
local version
|
||||||
version=$(echo "$redirect_url" | sed -E 's|.*/releases/tag/([^/]*)\s*$|\1|')
|
version=$(echo "$redirect_url" | sed -E 's|.*/releases/tag/([^/]*)\s*$|\1|')
|
||||||
|
|
||||||
if [ -z "$version" ] || [ "$version" = "$redirect_url" ]; then
|
if [ -z "$version" ] || [ "$version" = "$redirect_url" ]; then
|
||||||
echo -e "${YELLOW}⚠ Could not parse version from redirect URL: $redirect_url${NC}" >&2
|
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 -e "${YELLOW}Using fallback version ${FALLBACK_VERSION}${NC}" >&2
|
||||||
echo "$FALLBACK_VERSION"
|
echo "$FALLBACK_VERSION"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$version"
|
echo "$version"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,25 +91,25 @@ get_version() {
|
|||||||
# Download and install
|
# Download and install
|
||||||
install_lnk() {
|
install_lnk() {
|
||||||
local platform version
|
local platform version
|
||||||
|
|
||||||
echo -e "${BLUE}🔗 Installing lnk...${NC}"
|
echo -e "${BLUE}🔗 Installing lnk...${NC}"
|
||||||
|
|
||||||
platform=$(detect_platform)
|
platform=$(detect_platform)
|
||||||
version=$(get_version "$1")
|
version=$(get_version "$1")
|
||||||
|
|
||||||
echo -e "${BLUE}Version: ${version}${NC}"
|
echo -e "${BLUE}Version: ${version}${NC}"
|
||||||
echo -e "${BLUE}Platform: ${platform}${NC}"
|
echo -e "${BLUE}Platform: ${platform}${NC}"
|
||||||
|
|
||||||
# Download URL
|
# Download URL
|
||||||
local filename="lnk_${platform}.tar.gz"
|
local filename="lnk_${platform}.tar.gz"
|
||||||
local url="https://github.com/${REPO}/releases/download/${version}/${filename}"
|
local url="https://github.com/${REPO}/releases/download/${version}/${filename}"
|
||||||
|
|
||||||
echo -e "${BLUE}Downloading ${url}...${NC}"
|
echo -e "${BLUE}Downloading ${url}...${NC}"
|
||||||
|
|
||||||
# Create temporary directory
|
# Create temporary directory
|
||||||
local tmp_dir=$(mktemp -d)
|
local tmp_dir=$(mktemp -d)
|
||||||
cd "$tmp_dir"
|
cd "$tmp_dir"
|
||||||
|
|
||||||
# Download the binary
|
# Download the binary
|
||||||
if ! curl -sL "$url" -o "$filename"; then
|
if ! curl -sL "$url" -o "$filename"; then
|
||||||
echo -e "${RED}Error: Failed to download ${url}${NC}"
|
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}"
|
echo -e "${YELLOW}Available releases: https://github.com/${REPO}/releases${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if we got an HTML error page instead of the binary
|
# Check if we got an HTML error page instead of the binary
|
||||||
if file "$filename" 2>/dev/null | grep -q "HTML"; then
|
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}"
|
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}"
|
echo -e "${YELLOW}Available releases: https://github.com/${REPO}/releases${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract the binary
|
# Extract the binary
|
||||||
if ! tar -xzf "$filename"; then
|
if ! tar -xzf "$filename"; then
|
||||||
echo -e "${RED}Error: Failed to extract ${filename}${NC}"
|
echo -e "${RED}Error: Failed to extract ${filename}${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make binary executable
|
# Make binary executable
|
||||||
chmod +x "$BINARY_NAME"
|
chmod +x "$BINARY_NAME"
|
||||||
|
|
||||||
# Install to system directory
|
# Install to system directory
|
||||||
echo -e "${YELLOW}Installing to ${INSTALL_DIR} (requires sudo)...${NC}"
|
echo -e "${YELLOW}Installing to ${INSTALL_DIR} (requires sudo)...${NC}"
|
||||||
if ! sudo mv "$BINARY_NAME" "$INSTALL_DIR/"; then
|
if ! sudo mv "$BINARY_NAME" "$INSTALL_DIR/"; then
|
||||||
echo -e "${RED}Error: Failed to install binary${NC}"
|
echo -e "${RED}Error: Failed to install binary${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
cd - > /dev/null
|
cd - > /dev/null
|
||||||
rm -rf "$tmp_dir"
|
rm -rf "$tmp_dir"
|
||||||
|
|
||||||
echo -e "${GREEN}✅ lnk installed successfully!${NC}"
|
echo -e "${GREEN}✅ lnk installed successfully!${NC}"
|
||||||
echo -e "${GREEN}Run 'lnk --help' to get started.${NC}"
|
echo -e "${GREEN}Run 'lnk --help' to get started.${NC}"
|
||||||
|
|
||||||
# Test the installation
|
# Test the installation
|
||||||
if command -v lnk >/dev/null 2>&1; then
|
if command -v lnk >/dev/null 2>&1; then
|
||||||
echo -e "${GREEN}Installed version: $(lnk --version)${NC}"
|
echo -e "${GREEN}Installed version: $(lnk --version)${NC}"
|
||||||
@@ -177,4 +177,4 @@ if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run the installer
|
# Run the installer
|
||||||
install_lnk "$1"
|
install_lnk "$1"
|
||||||
|
Reference in New Issue
Block a user