Skip to content

Build and publish GitHub release #62

Build and publish GitHub release

Build and publish GitHub release #62

name: Build and publish GitHub release
on:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Install cargo toolchain (1.79.0)
uses: actions-rs/toolchain@v1
with:
toolchain: 1.79.0
- name: Install cargo toolchain (nightly-2024-07-17)
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2024-07-17
- name: Restore cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Restore PostgreSQL cache
id: cache-pgsql
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/temp/pgsql
key: pgsql-win-x64-15.3.4
- name: Download PostgreSQL binaries
if: steps.cache-pgsql.outputs.cache-hit != 'true'
uses: suisei-cn/actions-download-file@v1.4.0
with:
url: https://get.enterprisedb.com/postgresql/postgresql-15.3-4-windows-x64-binaries.zip
target: /temp/pg-dl/
filename: pg.zip
- name: Extract PostgreSQL binaries
if: steps.cache-pgsql.outputs.cache-hit != 'true'
shell: pwsh
run: 7z x -o"${{ github.workspace}}/temp/" /temp/pg-dl/pg.zip pgsql/lib/* pgsql/bin/*
- name: Build parcel-server
uses: actions-rs/cargo@v1
env:
PQ_LIB_DIR: ${{ github.workspace }}/temp/pgsql/lib
with:
toolchain: 1.79.0
command: build
args: --release -p parcel-server --target x86_64-pc-windows-msvc
- name: Build parcel-client
uses: actions-rs/cargo@v1
with:
toolchain: nightly-2024-07-17
command: build
args: --release -p parcel-client --target x86_64-pc-windows-msvc
- name: Build client-injector
uses: actions-rs/cargo@v1
with:
toolchain: nightly-2024-07-17
command: build
args: --release -p client-injector --target x86_64-pc-windows-msvc
- name: Move dist files to temp folder
run: |
mkdir ${{ github.workspace }}/dist-server/
mkdir ${{ github.workspace }}/dist-client/
cp ${{ github.workspace }}/target/x86_64-pc-windows-msvc/release/parcel-server.exe ${{ github.workspace }}/dist-server/
cp ${{ github.workspace }}/target/x86_64-pc-windows-msvc/release/parcel_server.pdb ${{ github.workspace }}/dist-server/
cp ${{ github.workspace }}/temp/pgsql/bin/libcrypto-3-x64.dll ${{ github.workspace }}/dist-server/
cp ${{ github.workspace }}/temp/pgsql/bin/libiconv-2.dll ${{ github.workspace }}/dist-server/
cp ${{ github.workspace }}/temp/pgsql/bin/libintl-9.dll ${{ github.workspace }}/dist-server/
cp ${{ github.workspace }}/temp/pgsql/bin/libpq.dll ${{ github.workspace }}/dist-server/
cp ${{ github.workspace }}/temp/pgsql/bin/libssl-3-x64.dll ${{ github.workspace }}/dist-server/
cp ${{ github.workspace }}/temp/pgsql/bin/libwinpthread-1.dll ${{ github.workspace }}/dist-server/
cp ${{ github.workspace }}/target/x86_64-pc-windows-msvc/release/parcel_client.dll ${{ github.workspace }}/dist-client/
cp ${{ github.workspace }}/target/x86_64-pc-windows-msvc/release/parcel_client.pdb ${{ github.workspace }}/dist-client/
cp ${{ github.workspace }}/target/x86_64-pc-windows-msvc/release/client-injector.exe ${{ github.workspace }}/dist-client/
cp ${{ github.workspace }}/target/x86_64-pc-windows-msvc/release/client_injector.pdb ${{ github.workspace }}/dist-client/
- name: Upload parcel-server artifact
uses: actions/upload-artifact@v3
with:
path: dist-server/*
name: parcel-server_x86_64-pc-windows-msvc
- name: Upload parcel-client artifact
uses: actions/upload-artifact@v3
with:
path: dist-client/*
name: parcel-client_x86_64-pc-windows-msvc
build-linux:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Install cargo toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.79.0
- name: Restore cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build parcel-server
uses: actions-rs/cargo@v1
with:
toolchain: 1.79.0
command: build
args: --release -p parcel-server --target x86_64-unknown-linux-gnu
- name: Upload parcel-server artifact
uses: actions/upload-artifact@v3
with:
name: parcel-server_x86_64-unknown-linux-gnu
path: target/x86_64-unknown-linux-gnu/release/parcel-server
create-release:
runs-on: ubuntu-latest
needs: [build-windows, build-linux]
steps:
- uses: actions/checkout@v3
- name: Download windows server artifact
uses: actions/download-artifact@v3
with:
name: parcel-server_x86_64-pc-windows-msvc
path: ./parcel-server_x86_64-pc-windows-msvc
- name: Download linux server artifact
uses: actions/download-artifact@v3
with:
name: parcel-server_x86_64-unknown-linux-gnu
path: ./parcel-server_x86_64-unknown-linux-gnu
- name: Download windows parcel-client artifact
uses: actions/download-artifact@v3
with:
name: parcel-client_x86_64-pc-windows-msvc
path: ./parcel-client_x86_64-pc-windows-msvc
- name: Copy game data json file to server data folder
run: |
mkdir ./parcel-server_x86_64-pc-windows-msvc/data/
mkdir ./parcel-server_x86_64-unknown-linux-gnu/data/
cp ./re-testing/exported-data.json ./parcel-server_x86_64-pc-windows-msvc/data/game_data.json
cp ./re-testing/exported-data.json ./parcel-server_x86_64-unknown-linux-gnu/data/game_data.json
- name: Create release zip files
run: |
zip -r ./parcel-server_x86_64-pc-windows-msvc.zip ./parcel-server_x86_64-pc-windows-msvc
zip -r ./parcel-server_x86_64-unknown-linux-gnu.zip ./parcel-server_x86_64-unknown-linux-gnu
zip -r ./parcel-client_x86_64-pc-windows-msvc.zip ./parcel-client_x86_64-pc-windows-msvc
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
draft: true
fail_on_unmatched_files: true
target_commitish: ${{ github.sha }}
generate_release_notes: true
files: |
./parcel-server_x86_64-pc-windows-msvc.zip
./parcel-server_x86_64-unknown-linux-gnu.zip
./parcel-client_x86_64-pc-windows-msvc.zip