Replace GoReleaser workflow with custom Release pipeline
Some checks failed
Release / goreleaser (push) Failing after 5m10s
Some checks failed
Release / goreleaser (push) Failing after 5m10s
This commit is contained in:
37
.github/workflows/go-releaser.yml
vendored
37
.github/workflows/go-releaser.yml
vendored
@@ -1,37 +0,0 @@
|
||||
name: goreleaser
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: stable
|
||||
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v5
|
||||
with:
|
||||
distribution: goreleaser
|
||||
version: latest
|
||||
args: release --clean
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Update latest tag
|
||||
run: |
|
||||
git tag -f latest
|
||||
git push -f origin latest
|
98
.github/workflows/release.yml
vendored
Normal file
98
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: stable
|
||||
|
||||
- name: Set up Git for Gitea
|
||||
run: |
|
||||
git config --global url."https://\token:${{ secrets.API_TOKEN }}@git.mvl.sh/".insteadOf "https://git.mvl.sh/"
|
||||
|
||||
- name: Build binaries
|
||||
id: build
|
||||
run: |
|
||||
# Get version from tag
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
echo "Building version ${VERSION}..."
|
||||
|
||||
# Set up directories
|
||||
mkdir -p dist/linux_amd64
|
||||
mkdir -p dist/linux_arm64
|
||||
mkdir -p dist/darwin_amd64
|
||||
mkdir -p dist/darwin_arm64
|
||||
|
||||
# Build for different platforms
|
||||
LDFLAGS="-s -w -X git.mvl.sh/vleeuwenmenno/sshtunnel/cmd.Version=${VERSION} -X git.mvl.sh/vleeuwenmenno/sshtunnel/cmd.BuildDate=$(date -u '+%Y-%m-%d %H:%M:%S')"
|
||||
|
||||
# Linux amd64
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS" -o dist/linux_amd64/sshtunnel
|
||||
tar -czf dist/sshtunnel_Linux_x86_64.tar.gz -C dist/linux_amd64 sshtunnel
|
||||
|
||||
# Linux arm64
|
||||
GOOS=linux GOARCH=arm64 go build -ldflags="$LDFLAGS" -o dist/linux_arm64/sshtunnel
|
||||
tar -czf dist/sshtunnel_Linux_arm64.tar.gz -C dist/linux_arm64 sshtunnel
|
||||
|
||||
# macOS amd64
|
||||
GOOS=darwin GOARCH=amd64 go build -ldflags="$LDFLAGS" -o dist/darwin_amd64/sshtunnel
|
||||
tar -czf dist/sshtunnel_Darwin_x86_64.tar.gz -C dist/darwin_amd64 sshtunnel
|
||||
|
||||
# macOS arm64
|
||||
GOOS=darwin GOARCH=arm64 go build -ldflags="$LDFLAGS" -o dist/darwin_arm64/sshtunnel
|
||||
tar -czf dist/sshtunnel_Darwin_arm64.tar.gz -C dist/darwin_arm64 sshtunnel
|
||||
|
||||
# Generate checksums
|
||||
cd dist && sha256sum *.tar.gz > checksums.txt
|
||||
|
||||
- name: Generate completion scripts
|
||||
run: |
|
||||
mkdir -p dist/completions
|
||||
# Generate completion scripts for different shells
|
||||
dist/linux_amd64/sshtunnel completion bash > dist/completions/sshtunnel.bash
|
||||
dist/linux_amd64/sshtunnel completion zsh > dist/completions/sshtunnel.zsh
|
||||
dist/linux_amd64/sshtunnel completion fish > dist/completions/sshtunnel.fish
|
||||
|
||||
- name: Create Gitea Release
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.API_TOKEN }}
|
||||
run: |
|
||||
# Get version from tag
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
|
||||
# Create release on Gitea
|
||||
curl -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-d "{\"tag_name\": \"$VERSION\", \"name\": \"$VERSION\", \"body\": \"Release $VERSION\"}" \
|
||||
"https://git.mvl.sh/api/v1/repos/vleeuwenmenno/sshtunnel/releases"
|
||||
|
||||
# Upload release assets
|
||||
for file in dist/*.tar.gz dist/checksums.txt; do
|
||||
echo "Uploading $file..."
|
||||
curl -X POST \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-F "attachment=@$file" \
|
||||
"https://git.mvl.sh/api/v1/repos/vleeuwenmenno/sshtunnel/releases/$VERSION/assets"
|
||||
done
|
||||
|
||||
- name: Update latest tag
|
||||
run: |
|
||||
git tag -f latest
|
||||
git push -f origin latest
|
Reference in New Issue
Block a user