Skip to content

Build and Release

Build and Release #23

Workflow file for this run

name: Build and Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.1'
- name: Get version from Version.go
id: get_version
run: |
$version = Select-String -Path Version.go -Pattern 'NowVersion\s*=\s*"([0-9]+\.[0-9]+\.[0-9]+)"' | ForEach-Object { $_.Matches.Groups[1].Value }
echo "VERSION=$version" >> $env:GITHUB_ENV
echo $version > version.txt
shell: pwsh
- name: Replace variables in code
run: |
(Get-Content RoomConnect.go) -replace 'AccessKey\s*=\s*".*"', "AccessKey = `"${{ secrets.ACCESSKEY }}`"" |
Set-Content RoomConnect.go
(Get-Content RoomConnect.go) -replace 'AccessSecret\s*=\s*".*"', "AccessSecret = `"${{ secrets.ACCESSSECRET }}`"" |
Set-Content RoomConnect.go
(Get-Content RoomConnect.go) -replace 'AppID\s*=\s*\d+', "AppID = ${{ secrets.APPID }}" |
Set-Content RoomConnect.go
shell: pwsh
- name: Build the executable
run: |
go build -o "BiliLine_v${{ env.VERSION }}.exe" -ldflags "-w -s -H=windowsgui"
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: BiliLine_
path: BiliLine_v${{ env.VERSION }}.exe
- name: Upload version
uses: actions/upload-artifact@v3
with:
name: version
path: version.txt
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download version
uses: actions/download-artifact@v3
with:
name: version
path: .
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: BiliLine_
path: .
- name: Display structure of downloaded files
run: pwd && ls -R
working-directory: .
- name: Read version
id: read_version
run: echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: Release ${{ env.VERSION }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "/home/runner/work/BiliLine_GUI/BiliLine_GUI/BiliLine_v${{ env.VERSION }}.exe"
asset_name: BiliLine_v${{ env.VERSION }}.exe
asset_content_type: application/octet-stream