50 lines
1.7 KiB
YAML
50 lines
1.7 KiB
YAML
name: Release Build
|
|
on:
|
|
push:
|
|
tags:
|
|
- v*
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
repository: 'GiteaAdmin/hello_gitea'
|
|
path: 'hello_gitea'
|
|
token: ${{ secrets.GITEATOKEN }}
|
|
ref: ${{ github.ref }}
|
|
|
|
- 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 }}" |