7 Commits

Author SHA1 Message Date
ee68d72fcd Исправлен workflow - 11 для сборки и релиза
Some checks failed
Release Build / release (push) Successful in 59s
Release Build / build-binaries (amd64, darwin, darwin-amd64) (push) Successful in 55s
Release Build / build-binaries (amd64, linux, linux-amd64) (push) Successful in 54s
Release Build / build-binaries (amd64, windows, windows-amd64.exe) (push) Successful in 53s
Release Build / build-binaries (arm64, darwin, darwin-arm64) (push) Successful in 53s
Release Build / build-binaries (arm64, linux, linux-arm64) (push) Successful in 55s
Release Build / create-docker-image (push) Failing after 1m8s
Release Build / create-release (push) Has been skipped
2025-07-27 14:28:27 +06:00
c5e580c627 Исправлен workflow - 10 для сборки и релиза 2025-07-27 14:16:54 +06:00
3734143548 Исправлен workflow - 9 для сборки и релиза
All checks were successful
Release Build / release (push) Successful in 1m2s
2025-07-27 13:45:32 +06:00
7858f1c55b Исправлен workflow - 8 для сборки и релиза
Some checks failed
Release Build / release (push) Failing after 1m46s
2025-07-27 13:41:09 +06:00
07a49d6cd4 Исправлен workflow - 7 для сборки и релиза
Some checks failed
Release Build / release (push) Failing after 50s
2025-07-27 13:33:06 +06:00
c8e8b45099 Исправлен workflow - 6 для сборки и релиза
Some checks failed
Release Build / release (push) Failing after 7s
2025-07-27 13:29:09 +06:00
5614bd6ada Исправлен workflow - 5 для сборки и релиза
Some checks failed
Release Build / release (push) Failing after 44s
2025-07-27 13:18:21 +06:00
5 changed files with 255 additions and 20 deletions

View File

@@ -0,0 +1,59 @@
name: Release Build
on:
push:
tags:
- v*
jobs:
release:
runs-on: ubuntu-latest
container:
image: golang:1.21
steps:
- name: Checkout repository
run: |
git clone https://oauth2:${{ secrets.GITEATOKEN }}@direct-dev.ru/gitea/GiteaAdmin/hello_gitea.git hello_gitea
cd hello_gitea
git checkout ${{ github.ref }}
- name: Setup Go
run: |
# Install jq for JSON parsing
apt-get update && apt-get install -y jq
git --version
go version
jq --version
- name: Build
run: |
cd hello_gitea
mkdir -p bin
go build -o bin/hello-api-${{ github.ref_name }} main.go
ls -la bin/
- name: Create Release
run: |
cd hello_gitea
# Create release using Gitea API
curl -X POST \
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"tag_name": "${{ github.ref_name }}",
"name": "Release ${{ github.ref_name }}",
"body": "Automated release",
"draft": false,
"prerelease": false
}' \
"https://direct-dev.ru/gitea/api/v1/repos/GiteaAdmin/hello_gitea/releases"
# Upload asset
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 }}" | \
jq -r '.id')
curl -X POST \
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @bin/hello-api-${{ github.ref_name }} \
"https://direct-dev.ru/gitea/api/v1/repos/GiteaAdmin/hello_gitea/releases/$RELEASE_ID/assets?name=hello-api-${{ github.ref_name }}"

View File

@@ -5,31 +5,160 @@ on:
- v*
jobs:
release:
build-binaries:
runs-on: ubuntu-latest
container:
image: golang:1.21
strategy:
matrix:
include:
- os: linux
arch: amd64
suffix: linux-amd64
- os: linux
arch: arm64
suffix: linux-arm64
- os: windows
arch: amd64
suffix: windows-amd64.exe
- os: darwin
arch: amd64
suffix: darwin-amd64
- os: darwin
arch: arm64
suffix: darwin-arm64
steps:
- uses: actions/checkout@v3
with:
repository: 'GiteaAdmin/hello_gitea'
path: 'hello_gitea'
token: ${{ secrets.GITEATOKEN }}
git-server-url: 'https://direct-dev.ru/gitea'
- name: Checkout repository
run: |
git clone https://oauth2:${{ secrets.GITEATOKEN }}@direct-dev.ru/gitea/GiteaAdmin/hello_gitea.git hello_gitea
cd hello_gitea
git checkout ${{ github.ref }}
- name: Build
- name: Setup Go
run: |
# Install jq for JSON parsing
apt-get update && apt-get install -y jq
git --version
go version
jq --version
- name: Build for ${{ matrix.os }}-${{ matrix.arch }}
run: |
cd hello_gitea
mkdir -p bin
go build -o bin/hello-api-${{ github.ref_name }} main.go
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o bin/hello-api-${{ matrix.suffix }} main.go
ls -la bin/
- name: Upload artifact
run: |
cd hello_gitea/bin
tar -czf hello-api-${{ matrix.suffix }}.tar.gz hello-api-${{ matrix.suffix }}
echo "Built: hello-api-${{ matrix.suffix }}.tar.gz"
create-docker-image:
runs-on: ubuntu-latest
container:
image: golang:1.21
needs: build-binaries
steps:
- name: Checkout repository
run: |
git clone https://oauth2:${{ secrets.GITEATOKEN }}@direct-dev.ru/gitea/GiteaAdmin/hello_gitea.git hello_gitea
cd hello_gitea
git checkout ${{ github.ref }}
- name: Setup Docker
run: |
# Install Docker CLI
apt-get update && apt-get install -y docker.io
docker --version
- name: Build Docker image
run: |
cd hello_gitea
# Build image using existing Dockerfile
docker build -t hello-api:${{ github.ref_name }} .
docker tag hello-api:${{ github.ref_name }} hello-api:latest
- name: Login to Docker Hub
run: |
echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Push to Docker Hub
run: |
cd hello_gitea
docker push ${{ secrets.DOCKERHUB_USERNAME }}/hello-api:${{ github.ref_name }}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/hello-api:latest
create-release:
runs-on: ubuntu-latest
container:
image: golang:1.21
needs: [build-binaries, create-docker-image]
steps:
- name: Checkout repository
run: |
git clone https://oauth2:${{ secrets.GITEATOKEN }}@direct-dev.ru/gitea/GiteaAdmin/hello_gitea.git hello_gitea
cd hello_gitea
git checkout ${{ github.ref }}
- name: Setup Go
run: |
# Install jq for JSON parsing
apt-get update && apt-get install -y jq
git --version
go version
jq --version
- name: Build all binaries
run: |
cd hello_gitea
mkdir -p bin
# Build for all platforms
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=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=arm64 go build -o bin/hello-api-darwin-arm64 main.go
# Create archives
cd bin
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-windows-amd64.tar.gz hello-api-windows-amd64.exe
tar -czf hello-api-darwin-amd64.tar.gz hello-api-darwin-amd64
tar -czf hello-api-darwin-arm64.tar.gz hello-api-darwin-arm64
ls -la
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITEATOKEN }}
GITHUB_API_URL: 'https://direct-dev.ru/gitea/api/v1'
with:
tag_name: ${{ github.ref_name }}
name: "Release ${{ github.ref_name }}"
body: "Automated release"
files: |
hello_gitea/bin/hello-api-${{ github.ref_name }}
run: |
cd hello_gitea
# Create release using Gitea API
curl -X POST \
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"tag_name": "${{ github.ref_name }}",
"name": "Release ${{ github.ref_name }}",
"body": "Automated release with multi-platform binaries and Docker image",
"draft": false,
"prerelease": false
}' \
"https://direct-dev.ru/gitea/api/v1/repos/GiteaAdmin/hello_gitea/releases"
# Upload assets
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 }}" | \
jq -r '.id')
# Upload all binaries
for file in bin/*.tar.gz; do
echo "Uploading $file..."
curl -X POST \
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @$file \
"https://direct-dev.ru/gitea/api/v1/repos/GiteaAdmin/hello_gitea/releases/$RELEASE_ID/assets?name=$(basename $file)"
done

1
.gitignore vendored
View File

@@ -25,3 +25,4 @@ go.work.sum
# env file
.env
bin/
dockerhub_token

46
Dockerfile Normal file
View File

@@ -0,0 +1,46 @@
# Build stage
FROM golang:1.21-alpine AS builder
# Install git and ca-certificates
RUN apk --no-cache add git ca-certificates
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o hello-api main.go
# Final stage
FROM alpine:latest
# Install jq and ca-certificates
RUN apk --no-cache add ca-certificates jq
# Create non-root user
RUN addgroup -g 1001 -S appgroup && \
adduser -u 1001 -S appuser -G appgroup
WORKDIR /app
# Copy binary from builder stage
COPY --from=builder /app/hello-api .
# Change ownership to non-root user
RUN chown appuser:appgroup hello-api
# Switch to non-root user
USER appuser
# Expose port (if your app uses one)
EXPOSE 8080
# Run the application
CMD ["./hello-api"]

View File

@@ -1,3 +1,3 @@
# hello_gitea
test repo to try with actions
test repo to try with actions - v1.0.11