Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
75822f7fb8 | |||
707cd82717 |
@@ -30,22 +30,28 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd hello_gitea
|
cd hello_gitea
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
|
echo "Building for all platforms..."
|
||||||
# Build for all platforms
|
# Build for all platforms
|
||||||
|
echo "Building for linux amd64..."
|
||||||
quick-build linux amd64
|
quick-build linux amd64
|
||||||
|
echo "Building for linux arm64..."
|
||||||
quick-build linux arm64
|
quick-build linux arm64
|
||||||
|
echo "Building for windows amd64..."
|
||||||
quick-build windows amd64
|
quick-build windows amd64
|
||||||
|
echo "Building for darwin amd64..."
|
||||||
quick-build darwin amd64
|
quick-build darwin amd64
|
||||||
|
echo "Building for darwin arm64..."
|
||||||
quick-build darwin arm64
|
quick-build darwin arm64
|
||||||
|
|
||||||
# Build for all platforms
|
# Build for all platforms - old variant
|
||||||
GOOS=linux GOARCH=amd64 go build -o bin/hello-api-linux-amd64 main.go
|
# GOOS=linux GOARCH=amd64 go build -o bin/hello-api-linux-amd64 main.go
|
||||||
GOOS=linux GOARCH=arm64 go build -o bin/hello-api-linux-arm64 main.go
|
# GOOS=linux GOARCH=arm64 go build -o bin/hello-api-linux-arm64 main.go
|
||||||
GOOS=windows GOARCH=amd64 go build -o bin/hello-api-windows-amd64.exe main.go
|
# GOOS=windows GOARCH=amd64 go build -o bin/hello-api-windows-amd64.exe main.go
|
||||||
GOOS=darwin GOARCH=amd64 go build -o bin/hello-api-darwin-amd64 main.go
|
# GOOS=darwin GOARCH=amd64 go build -o bin/hello-api-darwin-amd64 main.go
|
||||||
GOOS=darwin GOARCH=arm64 go build -o bin/hello-api-darwin-arm64 main.go
|
# GOOS=darwin GOARCH=arm64 go build -o bin/hello-api-darwin-arm64 main.go
|
||||||
|
|
||||||
# Create archives
|
# Create archives
|
||||||
|
echo "Creating archives..."
|
||||||
cd bin
|
cd bin
|
||||||
tar -czf hello-api-linux-amd64.tar.gz hello-api-linux-amd64
|
tar -czf hello-api-linux-amd64.tar.gz hello-api-linux-amd64
|
||||||
tar -czf hello-api-linux-arm64.tar.gz hello-api-linux-arm64
|
tar -czf hello-api-linux-arm64.tar.gz hello-api-linux-arm64
|
||||||
@@ -53,12 +59,14 @@ jobs:
|
|||||||
tar -czf hello-api-darwin-amd64.tar.gz hello-api-darwin-amd64
|
tar -czf hello-api-darwin-amd64.tar.gz hello-api-darwin-amd64
|
||||||
tar -czf hello-api-darwin-arm64.tar.gz hello-api-darwin-arm64
|
tar -czf hello-api-darwin-arm64.tar.gz hello-api-darwin-arm64
|
||||||
|
|
||||||
ls -la
|
echo "Listing bin directory..."
|
||||||
|
ls -la bin
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
run: |
|
run: |
|
||||||
cd hello_gitea
|
cd hello_gitea
|
||||||
# Create release using Gitea API
|
# Create release using Gitea API
|
||||||
|
echo "Creating release..."
|
||||||
curl -X POST \
|
curl -X POST \
|
||||||
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
|
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
@@ -71,12 +79,13 @@ jobs:
|
|||||||
}' \
|
}' \
|
||||||
"https://direct-dev.ru/gitea/api/v1/repos/GiteaAdmin/hello_gitea/releases"
|
"https://direct-dev.ru/gitea/api/v1/repos/GiteaAdmin/hello_gitea/releases"
|
||||||
|
|
||||||
# Upload assets
|
echo "Getting release id..."
|
||||||
RELEASE_ID=$(curl -s -H "Authorization: token ${{ secrets.GITEATOKEN }}" \
|
RELEASE_ID=$(curl -s -H "Authorization: token ${{ secrets.GITEATOKEN }}" \
|
||||||
"https://direct-dev.ru/gitea/api/v1/repos/GiteaAdmin/hello_gitea/releases/tags/${{ github.ref_name }}" | \
|
"https://direct-dev.ru/gitea/api/v1/repos/GiteaAdmin/hello_gitea/releases/tags/${{ github.ref_name }}" | \
|
||||||
jq -r '.id')
|
jq -r '.id')
|
||||||
|
|
||||||
# Upload all binaries
|
# Upload all binaries
|
||||||
|
echo "Uploading assets..."
|
||||||
for file in bin/*.tar.gz; do
|
for file in bin/*.tar.gz; do
|
||||||
echo "Uploading $file..."
|
echo "Uploading $file..."
|
||||||
curl -X POST \
|
curl -X POST \
|
||||||
@@ -86,6 +95,8 @@ jobs:
|
|||||||
"https://direct-dev.ru/gitea/api/v1/repos/GiteaAdmin/hello_gitea/releases/$RELEASE_ID/assets?name=$(basename $file)"
|
"https://direct-dev.ru/gitea/api/v1/repos/GiteaAdmin/hello_gitea/releases/$RELEASE_ID/assets?name=$(basename $file)"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "Release created successfully"
|
||||||
|
|
||||||
create-docker-image:
|
create-docker-image:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
@@ -111,7 +122,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
# Docker is already installed in docker:dind image
|
# Docker is already installed in docker:dind image
|
||||||
docker --version
|
docker --version
|
||||||
|
echo "Setting up Docker Buildx for multi-platform builds..."
|
||||||
# Setup Docker Buildx for multi-platform builds
|
# Setup Docker Buildx for multi-platform builds
|
||||||
docker buildx create --name go-buildx --use
|
docker buildx create --name go-buildx --use
|
||||||
docker buildx inspect --bootstrap
|
docker buildx inspect --bootstrap
|
||||||
@@ -123,6 +134,7 @@ jobs:
|
|||||||
- name: Build multi-platform Docker images
|
- name: Build multi-platform Docker images
|
||||||
run: |
|
run: |
|
||||||
cd hello_gitea
|
cd hello_gitea
|
||||||
|
echo "Building multi-platform images using buildx..."
|
||||||
# Build multi-platform images using buildx
|
# Build multi-platform images using buildx
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/amd64,linux/arm64 \
|
--platform linux/amd64,linux/arm64 \
|
||||||
@@ -130,8 +142,11 @@ jobs:
|
|||||||
--tag ${{ secrets.DOCKERHUB_USERNAME }}/hello-api:latest \
|
--tag ${{ secrets.DOCKERHUB_USERNAME }}/hello-api:latest \
|
||||||
--push \
|
--push \
|
||||||
.
|
.
|
||||||
|
echo "Multi-platform images built successfully"
|
||||||
|
|
||||||
- name: Remove buildx
|
- name: Remove buildx
|
||||||
run: |
|
run: |
|
||||||
|
echo "Removing buildx..."
|
||||||
docker buildx rm go-buildx
|
docker buildx rm go-buildx
|
||||||
|
|
||||||
update-to-release-branch:
|
update-to-release-branch:
|
||||||
@@ -142,6 +157,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Create Release Branch
|
- name: Create Release Branch
|
||||||
run: |
|
run: |
|
||||||
|
echo "Creating release branch..."
|
||||||
echo "=== GitHub Variables ==="
|
echo "=== GitHub Variables ==="
|
||||||
echo "github.ref = ${{ github.ref }}"
|
echo "github.ref = ${{ github.ref }}"
|
||||||
echo "github.ref_name = ${{ github.ref_name }}"
|
echo "github.ref_name = ${{ github.ref_name }}"
|
||||||
@@ -180,3 +196,4 @@ jobs:
|
|||||||
# Push changes to release branch
|
# Push changes to release branch
|
||||||
echo "Pushing changes to release branch..."
|
echo "Pushing changes to release branch..."
|
||||||
git push origin release --force
|
git push origin release --force
|
||||||
|
echo "Changes pushed to release branch successfully"
|
@@ -1,5 +1,5 @@
|
|||||||
# Build stage
|
# Build stage
|
||||||
FROM --platform=$BUILDPLATFORM golang:1.21-alpine AS builder
|
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS builder
|
||||||
|
|
||||||
# Install git and ca-certificates
|
# Install git and ca-certificates
|
||||||
RUN apk --no-cache add git ca-certificates
|
RUN apk --no-cache add git ca-certificates
|
||||||
|
2
main.go
2
main.go
@@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "1.0.33"
|
const version = "1.0.35"
|
||||||
|
|
||||||
// SystemInfo holds system information
|
// SystemInfo holds system information
|
||||||
type SystemInfo struct {
|
type SystemInfo struct {
|
||||||
|
2
makefile
2
makefile
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
BIN_DIR=bin
|
BIN_DIR=bin
|
||||||
APP_NAME=hello-api
|
APP_NAME=hello-api
|
||||||
VERSION=1.0.33
|
VERSION=1.0.35
|
||||||
|
|
||||||
build:
|
build:
|
||||||
mkdir -p $(BIN_DIR)
|
mkdir -p $(BIN_DIR)
|
||||||
|
@@ -13,7 +13,9 @@ fi
|
|||||||
|
|
||||||
# Собираем для указанной платформы
|
# Собираем для указанной платформы
|
||||||
if [ -n "$1" ] && [ -n "$2" ]; then
|
if [ -n "$1" ] && [ -n "$2" ]; then
|
||||||
GOOS=$1 GOARCH=$2 go build -o "hello-api-$1-$2" main.go
|
echo "Building for $1 $2..."
|
||||||
|
GOOS=$1 GOARCH=$2 go build -o "bin/hello-api-$1-$2" main.go
|
||||||
else
|
else
|
||||||
go build -o hello-api main.go
|
echo "Building for current platform..."
|
||||||
|
go build -o bin/hello-api main.go
|
||||||
fi
|
fi
|
Reference in New Issue
Block a user