Release v1.0.27
This commit is contained in:
@@ -5,120 +5,165 @@ on:
|
|||||||
- v*
|
- v*
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
create-docker-image:
|
# create-release:
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# container:
|
||||||
|
# # image: golang:1.21
|
||||||
|
# image: ${{ secrets.DOCKERHUB_USERNAME }}/my-build-golang-runner:latest
|
||||||
|
# needs: create-release-branch
|
||||||
|
# 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
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# create-docker-image:
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# container:
|
||||||
|
# image: docker:28.3.2-dind
|
||||||
|
# needs: create-release
|
||||||
|
# steps:
|
||||||
|
# - name: Checkout repository
|
||||||
|
# run: |
|
||||||
|
# # Install git
|
||||||
|
# apk add --no-cache git
|
||||||
|
|
||||||
|
# echo "=== GitHub Variables ==="
|
||||||
|
# echo "github.ref = ${{ github.ref }}"
|
||||||
|
# echo "github.ref_name = ${{ github.ref_name }}"
|
||||||
|
# echo "github.sha = ${{ github.sha }}"
|
||||||
|
# echo "github.repository = ${{ github.repository }}"
|
||||||
|
# echo "========================"
|
||||||
|
# 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 Buildx
|
||||||
|
# run: |
|
||||||
|
# # Docker is already installed in docker:dind image
|
||||||
|
# docker --version
|
||||||
|
|
||||||
|
# # Setup Docker Buildx for multi-platform builds
|
||||||
|
# docker buildx create --use
|
||||||
|
# docker buildx inspect --bootstrap
|
||||||
|
|
||||||
|
# - name: Login to Docker Hub
|
||||||
|
# run: |
|
||||||
|
# echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
||||||
|
|
||||||
|
# - name: Build multi-platform Docker images
|
||||||
|
# run: |
|
||||||
|
# cd hello_gitea
|
||||||
|
# # Build multi-platform images using buildx
|
||||||
|
# docker buildx build \
|
||||||
|
# --platform linux/amd64,linux/arm64 \
|
||||||
|
# --tag ${{ secrets.DOCKERHUB_USERNAME }}/hello-api:${{ github.ref_name }} \
|
||||||
|
# --tag ${{ secrets.DOCKERHUB_USERNAME }}/hello-api:latest \
|
||||||
|
# --push \
|
||||||
|
# .
|
||||||
|
|
||||||
|
create-release-branch:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: docker:28.3.2-dind
|
image: docker:28.3.2-dind
|
||||||
|
# needs: create-docker-image
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Create Release Branch
|
||||||
run: |
|
run: |
|
||||||
# Install git
|
|
||||||
apk add --no-cache git
|
|
||||||
|
|
||||||
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 }}"
|
||||||
echo "github.sha = ${{ github.sha }}"
|
echo "github.sha = ${{ github.sha }}"
|
||||||
echo "github.repository = ${{ github.repository }}"
|
echo "github.repository = ${{ github.repository }}"
|
||||||
echo "========================"
|
echo "========================"
|
||||||
|
# Clone repository
|
||||||
|
echo "Cloning repository..."
|
||||||
git clone https://oauth2:${{ secrets.GITEATOKEN }}@direct-dev.ru/gitea/GiteaAdmin/hello_gitea.git hello_gitea
|
git clone https://oauth2:${{ secrets.GITEATOKEN }}@direct-dev.ru/gitea/GiteaAdmin/hello_gitea.git hello_gitea
|
||||||
cd hello_gitea
|
cd hello_gitea
|
||||||
git checkout ${{ github.ref }}
|
|
||||||
|
|
||||||
- name: Setup Docker Buildx
|
# Configure git
|
||||||
run: |
|
echo "Configuring git..."
|
||||||
# Docker is already installed in docker:dind image
|
git config user.email "info@direct-dev.ru"
|
||||||
docker --version
|
git config user.name "Direct-Dev-Robot"
|
||||||
|
|
||||||
# Setup Docker Buildx for multi-platform builds
|
# Check if release branch exists
|
||||||
docker buildx create --use
|
echo "Checking if release branch exists..."
|
||||||
docker buildx inspect --bootstrap
|
if git ls-remote --heads origin release | grep -q release; then
|
||||||
|
echo "Release branch exists, checking out..."
|
||||||
|
git checkout release
|
||||||
|
echo "release branch exists - pulling release branch..."
|
||||||
|
git pull origin release
|
||||||
|
else
|
||||||
|
echo "release branch does not exist - creating new release branch..."
|
||||||
|
git checkout -b release
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
# Reset to the tag commit
|
||||||
run: |
|
echo "Resetting to the tag commit ${{ github.ref_name }} ..."
|
||||||
echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
git reset --hard ${{ github.ref_name }}
|
||||||
|
|
||||||
- name: Build multi-platform Docker images
|
# Push changes to release branch
|
||||||
run: |
|
echo "Pushing changes to release branch..."
|
||||||
cd hello_gitea
|
git push origin release --force
|
||||||
# Build multi-platform images using buildx
|
|
||||||
docker buildx build \
|
|
||||||
--platform linux/amd64,linux/arm64 \
|
|
||||||
--tag ${{ secrets.DOCKERHUB_USERNAME }}/hello-api:${{ github.ref_name }} \
|
|
||||||
--tag ${{ secrets.DOCKERHUB_USERNAME }}/hello-api:latest \
|
|
||||||
--push \
|
|
||||||
.
|
|
||||||
|
|
||||||
create-release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
# image: golang:1.21
|
|
||||||
image: ${{ secrets.DOCKERHUB_USERNAME }}/my-build-golang-runner:latest
|
|
||||||
needs: 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
|
|
||||||
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
|
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/amd64,linux/arm64 \
|
--platform linux/amd64,linux/arm64 \
|
||||||
--tag ${DOCKERHUB_USERNAME}/my-build-golang-runner:latest \
|
--tag "${DOCKERHUB_USERNAME:-kuznetcovay}"/my-build-golang-runner:latest \
|
||||||
--push \
|
--push \
|
||||||
-f Dockerfile_for_runner_image \
|
-f Dockerfile_for_runner_image \
|
||||||
.
|
.
|
124
build.yaml
Normal file
124
build.yaml
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
name: Release Build
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
create-docker-image:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: docker:28.3.2-dind
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
run: |
|
||||||
|
# Install git
|
||||||
|
apk add --no-cache git
|
||||||
|
|
||||||
|
echo "=== GitHub Variables ==="
|
||||||
|
echo "github.ref = ${{ github.ref }}"
|
||||||
|
echo "github.ref_name = ${{ github.ref_name }}"
|
||||||
|
echo "github.sha = ${{ github.sha }}"
|
||||||
|
echo "github.repository = ${{ github.repository }}"
|
||||||
|
echo "========================"
|
||||||
|
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 Buildx
|
||||||
|
run: |
|
||||||
|
# Docker is already installed in docker:dind image
|
||||||
|
docker --version
|
||||||
|
|
||||||
|
# Setup Docker Buildx for multi-platform builds
|
||||||
|
docker buildx create --use
|
||||||
|
docker buildx inspect --bootstrap
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
run: |
|
||||||
|
echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
||||||
|
|
||||||
|
- name: Build multi-platform Docker images
|
||||||
|
run: |
|
||||||
|
cd hello_gitea
|
||||||
|
# Build multi-platform images using buildx
|
||||||
|
docker buildx build \
|
||||||
|
--platform linux/amd64,linux/arm64 \
|
||||||
|
--tag ${{ secrets.DOCKERHUB_USERNAME }}/hello-api:${{ github.ref_name }} \
|
||||||
|
--tag ${{ secrets.DOCKERHUB_USERNAME }}/hello-api:latest \
|
||||||
|
--push \
|
||||||
|
.
|
||||||
|
|
||||||
|
create-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
# image: golang:1.21
|
||||||
|
image: ${{ secrets.DOCKERHUB_USERNAME }}/my-build-golang-runner:latest
|
||||||
|
needs: 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
|
||||||
|
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
|
2
main.go
2
main.go
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "1.0.26"
|
const version = "1.0.27"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Set Gin mode
|
// Set Gin mode
|
||||||
|
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.0
|
VERSION=1.0.27
|
||||||
|
|
||||||
build:
|
build:
|
||||||
mkdir -p $(BIN_DIR)
|
mkdir -p $(BIN_DIR)
|
||||||
|
@@ -37,7 +37,7 @@ get_version_interactive() {
|
|||||||
echo " Текущая версия: $CURRENT_VERSION"
|
echo " Текущая версия: $CURRENT_VERSION"
|
||||||
echo " Новая версия: $VERSION"
|
echo " Новая версия: $VERSION"
|
||||||
echo ""
|
echo ""
|
||||||
read -p "Продолжить? (y/N): " CONFIRM
|
read -r -p "Продолжить? (y/N): " CONFIRM
|
||||||
|
|
||||||
if [[ ! $CONFIRM =~ ^[Yy]$ ]]; then
|
if [[ ! $CONFIRM =~ ^[Yy]$ ]]; then
|
||||||
echo "❌ Релиз отменен"
|
echo "❌ Релиз отменен"
|
||||||
@@ -92,6 +92,24 @@ fi
|
|||||||
|
|
||||||
echo "✅ Версия обновлена в main.go"
|
echo "✅ Версия обновлена в main.go"
|
||||||
|
|
||||||
|
# Обновляем версию в makefile
|
||||||
|
echo "📝 Обновляем версию в makefile..."
|
||||||
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
# macOS
|
||||||
|
sed -i '' "s/^VERSION=.*/VERSION=$VERSION/" makefile
|
||||||
|
else
|
||||||
|
# Linux
|
||||||
|
sed -i "s/^VERSION=.*/VERSION=$VERSION/" makefile
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Проверяем, что изменение применилось
|
||||||
|
if ! grep -q "^VERSION=$VERSION" makefile; then
|
||||||
|
echo "Ошибка: Не удалось обновить версию в makefile"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✅ Версия обновлена в makefile"
|
||||||
|
|
||||||
# Выполняем git команды
|
# Выполняем git команды
|
||||||
echo "📦 Добавляем изменения в git..."
|
echo "📦 Добавляем изменения в git..."
|
||||||
git add .
|
git add .
|
||||||
@@ -109,6 +127,7 @@ git push --tags
|
|||||||
echo "🎉 Релиз v$VERSION успешно завершен!"
|
echo "🎉 Релиз v$VERSION успешно завершен!"
|
||||||
echo "📋 Выполненные действия:"
|
echo "📋 Выполненные действия:"
|
||||||
echo " - Обновлена версия в main.go"
|
echo " - Обновлена версия в main.go"
|
||||||
|
echo " - Обновлена версия в makefile"
|
||||||
echo " - Создан коммит с сообщением 'Release v$VERSION'"
|
echo " - Создан коммит с сообщением 'Release v$VERSION'"
|
||||||
echo " - Создан тег v$VERSION"
|
echo " - Создан тег v$VERSION"
|
||||||
echo " - Изменения отправлены в удаленный репозиторий"
|
echo " - Изменения отправлены в удаленный репозиторий"
|
@@ -1,76 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Скрипт для автоматизации релиза
|
|
||||||
# Использование: ./scripts/release.sh <version>
|
|
||||||
# Пример: ./scripts/release.sh 1.0.25
|
|
||||||
|
|
||||||
set -e # Остановить выполнение при ошибке
|
|
||||||
|
|
||||||
# Проверка аргументов
|
|
||||||
if [ $# -eq 0 ]; then
|
|
||||||
echo "Ошибка: Необходимо указать версию"
|
|
||||||
echo "Использование: $0 <version>"
|
|
||||||
echo "Пример: $0 1.0.25"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
VERSION=$1
|
|
||||||
|
|
||||||
# Проверка формата версии (простая проверка)
|
|
||||||
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
||||||
echo "Ошибка: Неверный формат версии. Используйте формат X.Y.Z (например, 1.0.25)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "🚀 Начинаем релиз версии v$VERSION..."
|
|
||||||
|
|
||||||
# Проверяем, что мы в git репозитории
|
|
||||||
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
|
||||||
echo "Ошибка: Не найден git репозиторий"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Проверяем, что нет незакоммиченных изменений
|
|
||||||
if ! git diff-index --quiet HEAD --; then
|
|
||||||
echo "Ошибка: Есть незакоммиченные изменения. Сначала закоммитьте их."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Обновляем версию в main.go
|
|
||||||
echo "📝 Обновляем версию в main.go..."
|
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
||||||
# macOS
|
|
||||||
sed -i '' "s/const version = \"[^\"]*\"/const version = \"$VERSION\"/" main.go
|
|
||||||
else
|
|
||||||
# Linux
|
|
||||||
sed -i "s/const version = \"[^\"]*\"/const version = \"$VERSION\"/" main.go
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Проверяем, что изменение применилось
|
|
||||||
if ! grep -q "const version = \"$VERSION\"" main.go; then
|
|
||||||
echo "Ошибка: Не удалось обновить версию в main.go"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "✅ Версия обновлена в main.go"
|
|
||||||
|
|
||||||
# Выполняем git команды
|
|
||||||
echo "📦 Добавляем изменения в git..."
|
|
||||||
git add .
|
|
||||||
|
|
||||||
echo "💾 Создаем коммит..."
|
|
||||||
git commit -m "Release v$VERSION"
|
|
||||||
|
|
||||||
echo "🏷️ Создаем тег..."
|
|
||||||
git tag -a "v$VERSION" -m "Release v$VERSION"
|
|
||||||
|
|
||||||
echo "🚀 Отправляем изменения и теги..."
|
|
||||||
git push
|
|
||||||
git push --tags
|
|
||||||
|
|
||||||
echo "🎉 Релиз v$VERSION успешно завершен!"
|
|
||||||
echo "📋 Выполненные действия:"
|
|
||||||
echo " - Обновлена версия в main.go"
|
|
||||||
echo " - Создан коммит с сообщением 'Release v$VERSION'"
|
|
||||||
echo " - Создан тег v$VERSION"
|
|
||||||
echo " - Изменения отправлены в удаленный репозиторий"
|
|
Reference in New Issue
Block a user