diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..1fcfe2e --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -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 }} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..082b194 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "makefile.configureOnOpen": false +} \ No newline at end of file diff --git a/bin/hello-api-1.0.0 b/bin/hello-api-1.0.0 new file mode 100755 index 0000000..4dbde42 Binary files /dev/null and b/bin/hello-api-1.0.0 differ diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..8f61163 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module direct-dev-ru/hello_gitea + +go 1.21 diff --git a/main.go b/main.go new file mode 100644 index 0000000..5717b68 --- /dev/null +++ b/main.go @@ -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) +} \ No newline at end of file diff --git a/makefile b/makefile new file mode 100644 index 0000000..f797d9b --- /dev/null +++ b/makefile @@ -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 ./... \ No newline at end of file