mirror of
https://github.com/Baipyrus/ProxySwitcher.git
synced 2024-12-26 04:31:45 +00:00
89 lines
2.0 KiB
YAML
89 lines
2.0 KiB
YAML
# This workflow will build a golang project
|
|
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
|
|
|
|
name: Publish
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
- 'pre*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
GOOS: windows
|
|
GOARCH: amd64
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Get GoLang version
|
|
run: sed -En 's/^go (.*)$/GO_VERSION=\1/p' go.mod >> $GITHUB_ENV
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "${{ env.GO_VERSION }}"
|
|
|
|
- name: Install dependencies
|
|
run: go get .
|
|
|
|
- name: Build project
|
|
run: go build -o build/ -v ./...
|
|
|
|
- name: Copying skripts and assets
|
|
run: |
|
|
cp run.ps1 build/
|
|
cp install.ps1 build/
|
|
cp -r configs/ build/
|
|
mkdir -p build/assets/
|
|
cp -r assets/*.ico build/assets/
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ProxySwitcher
|
|
path: build/
|
|
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: ProxySwitcher
|
|
path: artifacts/
|
|
|
|
- name: Zip artifacts for release
|
|
run: |
|
|
cd artifacts/
|
|
zip -r ../ProxySwitcher.zip *
|
|
|
|
- name: Create release
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
RELEASE_NAME: ${{ github.ref_name }}
|
|
run: |
|
|
# If the release name starts with "pre", draft release
|
|
FLAGS=()
|
|
TITLE="Release $RELEASE_NAME"
|
|
if [[ "$RELEASE_NAME" == pre* ]]; then
|
|
FLAGS+=(--prerelease --draft)
|
|
TITLE="Prerelease $RELEASE_NAME"
|
|
fi
|
|
|
|
# Create the release with the appropriate flags
|
|
gh release create "$RELEASE_NAME" \
|
|
--title "$TITLE" \
|
|
"${FLAGS[@]}" \
|
|
ProxySwitcher.zip
|