190 lines
5.0 KiB
YAML
190 lines
5.0 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build-and-release-linux:
|
|
name: Build and Release for Linux
|
|
runs-on: [self-hosted, linux, arm64]
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: '1.22.3'
|
|
|
|
- name: Build for Linux
|
|
run: go build -o myapp
|
|
|
|
- name: Create Release
|
|
id: create_release
|
|
uses: actions/create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ github.ref_name }}
|
|
release_name: Release ${{ github.ref_name }}
|
|
body: Release notes for ${{ github.ref_name }}
|
|
draft: false
|
|
prerelease: false
|
|
|
|
- name: Save upload_url
|
|
run: echo "UPLOAD_URL=${{ steps.create_release.outputs.upload_url }}" > upload_url.txt
|
|
shell: bash
|
|
|
|
- name: Upload upload_url artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: upload_url
|
|
path: upload_url.txt
|
|
|
|
build-and-release-windows:
|
|
name: Build and Release for Windows
|
|
runs-on: windows-latest
|
|
needs: build-and-release-linux
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: '1.22.3'
|
|
|
|
- name: Build for Windows
|
|
run: go build -o myapp.exe
|
|
|
|
- name: Download upload_url artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: upload_url
|
|
path: .
|
|
|
|
- name: Read upload_url
|
|
id: read_upload_url
|
|
run: |
|
|
UPLOAD_URL=$(cat upload_url.txt)
|
|
echo "::set-output name=upload_url::$UPLOAD_URL"
|
|
shell: bash
|
|
|
|
- name: Debug upload_url
|
|
run: |
|
|
echo "Upload URL: ${{ steps.read_upload_url.outputs.upload_url }}"
|
|
|
|
- name: Upload Windows Release Asset
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ steps.read_upload_url.outputs.upload_url }}
|
|
asset_path: ./myapp.exe
|
|
asset_name: myapp-windows.exe
|
|
asset_content_type: application/octet-stream
|
|
|
|
|
|
# name: Yoink Release
|
|
|
|
# on:
|
|
# push:
|
|
# tags:
|
|
# - 'v*'
|
|
|
|
# jobs:
|
|
# yoink-release:
|
|
# name: Yoink Build and Release
|
|
# runs-on: [self-hosted, linux, arm64]
|
|
|
|
# steps:
|
|
# - name: Checkout
|
|
# uses: actions/checkout@v3
|
|
|
|
# - name: Setup Go
|
|
# uses: actions/setup-go@v4
|
|
# with:
|
|
# go-version: '1.22.3'
|
|
|
|
# - name: Linux Build
|
|
# run: go build -o yoink
|
|
|
|
# - name: Create Release
|
|
# id: create_release
|
|
# uses: actions/create-release@v1
|
|
# env:
|
|
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
# with:
|
|
# tag_name: ${{ github.ref_name }}
|
|
# release_name: Release ${{ github.ref_name }}
|
|
# body: Release notes for ${{ github.ref_name }}
|
|
# draft: false
|
|
# prerelease: false
|
|
|
|
# - name: Save upload_url
|
|
# run: echo "UPLOAD_URL=${{ steps.create_release.outputs.upload_url }}" > upload_url.txt
|
|
# shell: bash
|
|
|
|
# - name: Upload upload_url artifact
|
|
# uses: actions/upload-artifact@v3
|
|
# with:
|
|
# name: upload_url.txt
|
|
# path: ./upload_url.txt
|
|
|
|
# - name: Upload Linux Release Asset
|
|
# uses: actions/upload-release-asset@v1
|
|
# env:
|
|
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
# with:
|
|
# upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
# asset_path: ./yoink
|
|
# asset_name: yoink
|
|
# asset_content_type: application/x-executable
|
|
|
|
# build-and-release-win:
|
|
# runs-on: windows-latest
|
|
# needs: yoink-release
|
|
|
|
# steps:
|
|
# - name: Checkout
|
|
# uses: actions/checkout@v3
|
|
|
|
# - name: Setup Go
|
|
# uses: actions/setup-go@v4
|
|
# with:
|
|
# go-version: '1.22.3'
|
|
|
|
# - name: Windows Build
|
|
# run: go build -o yoink.exe
|
|
|
|
# - name: Download upload_url artifact
|
|
# uses: actions/download-artifact@v3
|
|
# with:
|
|
# name: upload_url.txt
|
|
# path: .
|
|
|
|
# - name: Read upload_url artifact
|
|
# id: read_upload_url
|
|
# run: |
|
|
# UPLOAD_URL=$(cat upload_url.txt)
|
|
# echo "::set-output name=upload_url::$UPLOAD_URL"
|
|
# shell: bash
|
|
|
|
# - name: Debug upload_url
|
|
# run: echo ${{ steps.read_upload_url.outputs.upload_url }}
|
|
# shell: bash
|
|
|
|
# - name: Upload Windows Release Asset
|
|
# uses: actions/upload-release-asset@v1
|
|
# env:
|
|
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
# with:
|
|
# upload_url: ${{ steps.read_upload_url.outputs.upload_url }}
|
|
# asset_path: ./yoink.exe
|
|
# asset_name: yoink.exe
|
|
# asset_content_type: application/x-executable |