Skip to content

Updated CI workflows to produce tar/zip files for releases. #107

Updated CI workflows to produce tar/zip files for releases.

Updated CI workflows to produce tar/zip files for releases. #107

Workflow file for this run

name: CI
on:
push:
pull_request:
schedule:
- cron: '0 0 1 * *' # Run at 00:00 on the first day of every month
release:
types: [published] # Trigger when a release is published
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
compiler: gcc
releaseArtifact: shinysocks-ubuntu
- os: windows-latest
compiler: msvc
releaseArtifact: shinysocks-win64
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Cache
uses: actions/cache@v4
with:
path: |
~/vcpkg
./build/vcpkg_installed
${{ env.HOME }}/.cache/vcpkg/archives
${{ env.XDG_CACHE_HOME }}/vcpkg/archives
${{ env.LOCALAPPDATA }}\vcpkg\archives
${{ env.APPDATA }}\vcpkg\archives
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ env.BUILD_TYPE }}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./vcpkg.json')}}
restore-keys: |
${{ runner.os }}-${{ env.BUILD_TYPE }}-
- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.compiler }}
vcvarsall: ${{ contains(matrix.os, 'windows') }}
cmake: true
ninja: true
vcpkg: true
cppcheck: false
- name: Prepare the PATH
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
echo "$env:USERPROFILE\vcpkg" >> $GITHUB_PATH
echo "$env:USERPROFILE\ninja" >> $GITHUB_PATH
else
echo "$HOME/vcpkg" >> $GITHUB_PATH
echo "$HOME/ninja" >> $GITHUB_PATH
fi
shell: bash
- name: Install dependencies
run: |
vcpkg install
- name: Build project
shell: bash
run: |
if [ -d build ]; then
echo "Build dir exists"
ls -la build
else
mkdir build
fi
pushd build
cmake .. -DCMAKE_BUILD_TYPE=Release -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build .
popd
- name: Install curl
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
choco install curl
else
sudo apt-get install -y curl
fi
shell: bash
- name: Test shinysocks
run: |
./build/bin/shinysocks -c "" -l debug &
SHINYSOCKS_PID=$!
sleep 5
curl -L --socks5-hostname socks5://localhost:1080 https://raw.githubusercontent.com/jgaa/shinysocks/master/ci/test.txt
if [ $? -ne 0 ]; then
echo "Curl command failed"
exit 1
fi
kill $SHINYSOCKS_PID
shell: bash
- name: Prepare artifacts
run: |
mkdir -p artifacts
if [[ "${{ runner.os }}" == "Windows" ]]; then
powershell -Command "& { Get-ChildItem -Path build/bin/* | Compress-Archive -DestinationPath artifacts/${{ matrix.releaseArtifact }}.zip }"
else
tar -czf artifacts/${{ matrix.releaseArtifact }}.tar.gz -C build/bin .
fi
shell: bash
- name: Upload CI Artifacts
uses: actions/upload-artifact@v4
with:
name: shinysocks-${{ matrix.os }}-${{ matrix.compiler }}
path: artifacts/*
retention-days: 1
- name: Upload Release Artifact
if: github.event_name == 'release' && matrix.releaseArtifact
uses: softprops/action-gh-release@v2
with:
files: artifacts/*
name: ${{ matrix.releaseArtifact }}
token: ${{ secrets.GITHUB_TOKEN }}