2024-09-01 11:01:45 +00:00
|
|
|
# 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
|
|
|
|
|
2024-09-01 13:52:01 +00:00
|
|
|
name: Publish
|
2024-09-01 11:01:45 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2024-09-06 09:41:27 +00:00
|
|
|
tags:
|
|
|
|
- 'v*'
|
|
|
|
- 'pre*'
|
2024-09-01 11:01:45 +00:00
|
|
|
|
2024-09-01 11:19:16 +00:00
|
|
|
jobs:
|
2024-09-01 11:01:45 +00:00
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
2024-09-01 11:53:50 +00:00
|
|
|
|
2024-09-01 14:08:24 +00:00
|
|
|
env:
|
|
|
|
GOOS: windows
|
|
|
|
GOARCH: amd64
|
|
|
|
|
2024-09-01 11:01:45 +00:00
|
|
|
steps:
|
2024-09-01 14:08:24 +00:00
|
|
|
- name: Checkout repository
|
2024-09-01 12:43:10 +00:00
|
|
|
uses: actions/checkout@v4
|
2024-09-01 11:53:50 +00:00
|
|
|
|
2024-09-01 12:43:10 +00:00
|
|
|
- name: Get GoLang version
|
|
|
|
run: sed -En 's/^go (.*)$/GO_VERSION=\1/p' go.mod >> $GITHUB_ENV
|
|
|
|
|
2024-09-01 11:01:45 +00:00
|
|
|
- name: Set up Go
|
2024-09-01 13:52:01 +00:00
|
|
|
uses: actions/setup-go@v5
|
2024-09-01 11:01:45 +00:00
|
|
|
with:
|
|
|
|
go-version: "${{ env.GO_VERSION }}"
|
2024-09-01 11:53:50 +00:00
|
|
|
|
2024-09-01 11:01:45 +00:00
|
|
|
- name: Install dependencies
|
2024-09-01 14:24:42 +00:00
|
|
|
run: go get .
|
2024-09-01 11:01:45 +00:00
|
|
|
|
|
|
|
- name: Build project
|
2024-09-01 11:53:50 +00:00
|
|
|
run: go build -o build/ -v ./...
|
2024-09-01 11:01:45 +00:00
|
|
|
|
2024-09-06 08:44:25 +00:00
|
|
|
- name: Copying skripts and assets
|
|
|
|
run: |
|
|
|
|
cp run.ps1 build/
|
|
|
|
cp install.ps1 build/
|
|
|
|
cp configs.json build/
|
|
|
|
cp -r assets/ build/
|
|
|
|
|
2024-09-01 13:36:17 +00:00
|
|
|
- name: Upload artifact
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: ProxySwitcher
|
2024-09-06 08:44:25 +00:00
|
|
|
path: build/
|
2024-09-01 13:52:01 +00:00
|
|
|
|
|
|
|
release:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: build
|
|
|
|
|
|
|
|
steps:
|
2024-09-01 14:08:24 +00:00
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
2024-09-01 13:52:01 +00:00
|
|
|
- name: Download artifact
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
name: ProxySwitcher
|
2024-09-01 14:24:42 +00:00
|
|
|
path: artifacts/
|
2024-09-01 13:52:01 +00:00
|
|
|
|
2024-09-06 08:44:25 +00:00
|
|
|
- name: Zip artifacts for release
|
|
|
|
run: |
|
|
|
|
cd artifacts/
|
|
|
|
zip ../ProxySwitcher.zip *
|
|
|
|
|
2024-09-01 13:52:01 +00:00
|
|
|
- name: Create release
|
|
|
|
env:
|
|
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2024-09-06 09:41:27 +00:00
|
|
|
RELEASE_NAME: ${{ github.ref_name }}
|
2024-09-01 13:52:01 +00:00
|
|
|
run: |
|
2024-09-06 09:41:27 +00:00
|
|
|
# If the release name starts with "pre", draft release
|
2024-09-06 09:47:07 +00:00
|
|
|
FLAGS=()
|
|
|
|
TITLE="Release $RELEASE_NAME"
|
2024-09-06 09:41:27 +00:00
|
|
|
if [[ "$RELEASE_NAME" == pre* ]]; then
|
2024-09-06 09:47:07 +00:00
|
|
|
FLAGS+=(--prerelease --draft)
|
|
|
|
TITLE="Prerelease $RELEASE_NAME"
|
2024-09-06 09:41:27 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Create the release with the appropriate flags
|
|
|
|
gh release create "$RELEASE_NAME" \
|
2024-09-06 09:47:07 +00:00
|
|
|
--title "$TITLE" \
|
|
|
|
"${FLAGS[@]}" \
|
2024-09-06 08:44:25 +00:00
|
|
|
ProxySwitcher.zip
|