Добавлен workflow для сборки и релиза

This commit is contained in:
2025-07-27 12:40:09 +06:00
parent 4022255201
commit 90c08975f0
6 changed files with 82 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
name: Release Build
on:
push:
tags:
- v*
jobs:
release:
runs-on: [your-runner-name]
steps:
- uses: actions/checkout@v3
- name: Build
run: |
mkdir -p bin
go build -o bin/hello-api-${{ github.ref_name }} main.go
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITEATOKEN }}
GITEA_TOKEN: ${{ secrets.GITEATOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: "Release ${{ github.ref }}"
body: "Automated release"
draft: false
prerelease: false
- name: Upload Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITEATOKEN }}
GITEA_TOKEN: ${{ secrets.GITEATOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/hello-api-${{ github.ref_name }}
asset_name: hello-api-${{ github.ref_name }}

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"makefile.configureOnOpen": false
}

BIN
bin/hello-api-1.0.0 Executable file

Binary file not shown.

3
go.mod Normal file
View File

@@ -0,0 +1,3 @@
module direct-dev-ru/hello_gitea
go 1.21

23
main.go Normal file
View File

@@ -0,0 +1,23 @@
package main
import (
"fmt"
"net/http"
"os"
)
const version = "1.0.0"
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, World! (Version %s)\n", version)
})
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
fmt.Printf("Server starting on port %s...\n", port)
http.ListenAndServe(":"+port, nil)
}

15
makefile Normal file
View File

@@ -0,0 +1,15 @@
.PHONY: build clean test
BIN_DIR=bin
APP_NAME=hello-api
VERSION=1.0.0
build:
mkdir -p $(BIN_DIR)
go build -o $(BIN_DIR)/$(APP_NAME)-$(VERSION) main.go
clean:
rm -rf $(BIN_DIR)
test:
go test -v ./...