mirror of
https://github.com/Baipyrus/ProxySwitcher.git
synced 2024-12-27 05:01:45 +00:00
Merge pull request #9 from Baipyrus/cicd-release-install
Adding All Installation Contents To Release
This commit is contained in:
commit
4f6016e373
36
.github/workflows/publish.yml
vendored
36
.github/workflows/publish.yml
vendored
@ -5,7 +5,9 @@ name: Publish
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags: 'v*'
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
- 'pre*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -33,11 +35,19 @@ jobs:
|
|||||||
- name: Build project
|
- name: Build project
|
||||||
run: go build -o build/ -v ./...
|
run: go build -o build/ -v ./...
|
||||||
|
|
||||||
|
- name: Copying skripts and assets
|
||||||
|
run: |
|
||||||
|
cp run.ps1 build/
|
||||||
|
cp install.ps1 build/
|
||||||
|
cp configs.json build/
|
||||||
|
mkdir -p build/assets/
|
||||||
|
cp -r assets/*.ico build/assets/
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ProxySwitcher
|
name: ProxySwitcher
|
||||||
path: build/*
|
path: build/
|
||||||
|
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -53,10 +63,26 @@ jobs:
|
|||||||
name: ProxySwitcher
|
name: ProxySwitcher
|
||||||
path: artifacts/
|
path: artifacts/
|
||||||
|
|
||||||
|
- name: Zip artifacts for release
|
||||||
|
run: |
|
||||||
|
cd artifacts/
|
||||||
|
zip -r ../ProxySwitcher.zip *
|
||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
RELEASE_NAME: ${{ github.ref_name }}
|
||||||
run: |
|
run: |
|
||||||
gh release create "${{ github.ref_name }}" \
|
# If the release name starts with "pre", draft release
|
||||||
--title "Release ${{ github.ref_name }}" \
|
FLAGS=()
|
||||||
artifacts/*
|
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
|
||||||
|
14
README.md
14
README.md
@ -17,12 +17,16 @@ save configurations, or exit the application.
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
- Simply run the following command in a Windows PowerShell:
|
You should download the [latest release](https://github.com/Baipyrus/ProxySwitcher/releases)
|
||||||
|
archive, **extract all contents** to a dedicated directory and then simply execute
|
||||||
|
the [`.\install.ps1`](.\install.ps1) script within a Windows Powershell.
|
||||||
|
|
||||||
```powershell
|
Alternatively, you could simply run the following command in a Windows PowerShell:
|
||||||
# Using 'Invoke-RestMethod' and 'Invoke-Expression'
|
|
||||||
irm 'https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/install.ps1' | iex
|
```powershell
|
||||||
```
|
# Using 'Invoke-RestMethod' and 'Invoke-Expression'
|
||||||
|
irm 'https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/install.ps1' | iex
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
45
install.ps1
45
install.ps1
@ -16,6 +16,10 @@ if (Test-Path "$powershellPath\pwsh.exe")
|
|||||||
{ $powershellPath = "$powershellPath\powershell.exe"
|
{ $powershellPath = "$powershellPath\powershell.exe"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Detect if current dir is release asset
|
||||||
|
$isRelease = Test-Path ".\ProxySwitcher.exe"
|
||||||
|
$releaseDir = (Get-Location).Path
|
||||||
|
|
||||||
# Create program directory and relocate
|
# Create program directory and relocate
|
||||||
Write-Host "Creating program directory in Userprofile..." -ForegroundColor Cyan
|
Write-Host "Creating program directory in Userprofile..." -ForegroundColor Cyan
|
||||||
$programDir = "ProxySwitcher"
|
$programDir = "ProxySwitcher"
|
||||||
@ -29,33 +33,23 @@ if ($startupDir -ne $destinationDir)
|
|||||||
Set-Location $programDir
|
Set-Location $programDir
|
||||||
$programPath = "$destinationDir\$programDir"
|
$programPath = "$destinationDir\$programDir"
|
||||||
|
|
||||||
# Download functional files from github as-is
|
if ($isRelease)
|
||||||
Write-Host "Downloading program into local directory..." -ForegroundColor Cyan
|
|
||||||
function DownloadFile
|
|
||||||
{
|
{
|
||||||
param (
|
# Copy release assets to program dir
|
||||||
[string]$url
|
Write-Host "Copying program into local directory..." -ForegroundColor Cyan
|
||||||
)
|
Copy-Item -Path "$releaseDir\*" -Destination $programPath -Recurse -Force
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
# Specify temporary output Path
|
||||||
|
$tmpPRSWzip = "$env:TMP\ProxySwitcher.zip"
|
||||||
|
|
||||||
$fileName = $url.Split("/")[-1]
|
# Download release files from github as-is
|
||||||
Invoke-RestMethod $url -OutFile $fileName
|
Write-Host "Downloading program into local directory..." -ForegroundColor Cyan
|
||||||
|
Invoke-RestMethod "https://github.com/Baipyrus/ProxySwitcher/releases/latest/download/ProxySwitcher.zip" -OutFile $tmpPRSWzip
|
||||||
|
|
||||||
|
# Expand Archive to program directory
|
||||||
|
Expand-Archive $tmpPRSWzip -DestinationPath $programPath -Force
|
||||||
}
|
}
|
||||||
DownloadFile -url https://github.com/Baipyrus/ProxySwitcher/releases/latest/download/ProxySwitcher.exe
|
|
||||||
DownloadFile -url https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/configs.json
|
|
||||||
DownloadFile -url https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/run.ps1
|
|
||||||
|
|
||||||
# Create assets directory and relocate
|
|
||||||
Write-Host "Downloading assets into local directory..." -ForegroundColor Cyan
|
|
||||||
$assetsDir = "assets"
|
|
||||||
if (-not (Test-Path $assetsDir))
|
|
||||||
{ New-Item -ItemType Directory -Path $assetsDir | Out-Null
|
|
||||||
}
|
|
||||||
Set-Location $assetsDir
|
|
||||||
$assetPath = "$programPath\assets\ICON_Enabled.ico"
|
|
||||||
|
|
||||||
# Download asset files from github
|
|
||||||
DownloadFile -url https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/assets/ICON_Disabled.ico
|
|
||||||
DownloadFile -url https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/assets/ICON_Enabled.ico
|
|
||||||
|
|
||||||
# Add program to PATH for cli application
|
# Add program to PATH for cli application
|
||||||
$userpath = [System.Environment]::GetEnvironmentVariable("PATH", "User")
|
$userpath = [System.Environment]::GetEnvironmentVariable("PATH", "User")
|
||||||
@ -64,14 +58,13 @@ $userpath = $userpath + ";$programDir"
|
|||||||
|
|
||||||
# Create Startmenu Shortcut
|
# Create Startmenu Shortcut
|
||||||
Write-Host "Creating shortcuts for easy access..." -ForegroundColor Cyan
|
Write-Host "Creating shortcuts for easy access..." -ForegroundColor Cyan
|
||||||
$assetsDir = "assets"
|
|
||||||
$shell = New-Object -comObject WScript.Shell
|
$shell = New-Object -comObject WScript.Shell
|
||||||
$shortcutPath = "$startmenuDir\Proxy Switcher.lnk"
|
$shortcutPath = "$startmenuDir\Proxy Switcher.lnk"
|
||||||
$shortcut = $shell.CreateShortcut($shortcutPath)
|
$shortcut = $shell.CreateShortcut($shortcutPath)
|
||||||
$shortcut.TargetPath = $powershellPath
|
$shortcut.TargetPath = $powershellPath
|
||||||
$shortcut.WorkingDirectory = $programPath
|
$shortcut.WorkingDirectory = $programPath
|
||||||
$shortcut.Arguments = "-ExecutionPolicy Bypass -NonInteractive -NoProfile -WindowStyle Hidden -File ""$programPath\run.ps1"""
|
$shortcut.Arguments = "-ExecutionPolicy Bypass -NonInteractive -NoProfile -WindowStyle Hidden -File ""$programPath\run.ps1"""
|
||||||
$shortcut.IconLocation = $assetPath
|
$shortcut.IconLocation = "$programPath\assets\ICON_Enabled.ico"
|
||||||
$shortcut.WindowStyle = 7
|
$shortcut.WindowStyle = 7
|
||||||
$shortcut.Save()
|
$shortcut.Save()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user