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 }}