diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 753b6b7..74f5241 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,10 @@ -name: link +name: Build -on: [push, pull_request] +on: + push: + branches: + - "main" + pull_request: env: OAT_VERSION: "0.21.2" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3fa619d..4ef19bd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,5 @@ name: Release + on: push: tags: @@ -8,8 +9,19 @@ env: OAT_VERSION: "0.21.2" jobs: - create_release: - name: Create GitHub Release + create-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + draft: true + allowUpdates: true + omitBodyDuringUpdate: true + + build-artifacts: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -34,13 +46,42 @@ jobs: Linker -v "$folder" done - - name: Create ZIP archive + - name: Create release artifacts run: ./scripts/release.sh - - - uses: marvinpinto/action-automatic-releases@latest + + - name: Upload release binaries + uses: actions/upload-artifact@v4 + with: + name: rawfiles-release + path: launcher-files + + release: + needs: + - create-release + - build-artifacts + runs-on: ubuntu-latest + permissions: + actions: read + contents: write + steps: + - uses: actions/download-artifact@v5 + with: + name: rawfiles-release + path: launcher-files + - name: Prepare release tool + run: | + wget -O release-tool.tar.gz https://github.com/iw4x/launcher/releases/latest/download/release-tool-x86_64-unknown-linux-gnu.tar.gz + tar -xvf release-tool.tar.gz + chmod +x release-tool + - name: Create release information + run: ./release-tool ./launcher-files + - uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - repo_token: '${{ secrets.GITHUB_TOKEN }}' - prerelease: false + artifacts: "launcher-files/**/*.*" + artifactErrorsFailBuild: true + allowUpdates: true draft: true - files: | - release.zip + omitBodyDuringUpdate: true + omitDraftDuringUpdate: true diff --git a/scripts/release.sh b/scripts/release.sh index 94bcd2d..0735d48 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,48 +1,55 @@ #!/bin/bash +# Exit and fail on first failing command +set -e + +# Check for sudo +if command -v sudo >/dev/null 2>&1; then SUDO='sudo'; else SUDO=''; fi + # set work_dir to the parent of this scripts location work_dir=$(dirname `cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd`) iwd_files=( "iw4x_00" "iw4x_01" "iw4x_02" "iw4x_03" "iw4x_04" "iw4x_05" ) # ensure dependencies are installed -sudo apt update >> /dev/null && sudo apt install zip curl -y >> /dev/null +$SUDO apt-get update +$SUDO apt-get install zip curl -y + +# create dirs +mkdir -p $work_dir/{zip-files,launcher-files} -# create release dir -mkdir $work_dir/release +# copy artifacts to zip-files dir +cp iw4x.exe $work_dir/launcher-files/ +cp -r $work_dir/{iw4x,zone} $work_dir/zip-files/ -# copy artifacts to release dir -cp iw4x.exe $work_dir/release/ -cp iw4sp.exe $work_dir/release/ -cp -r $work_dir/zone/ $work_dir/release/ -cp -r $work_dir/iw4x/ $work_dir/release/ # copy language fast files -mkdir -p $work_dir/release/zone/patch -cp $work_dir/zone_out/*/*.ff $work_dir/release/zone/patch/ +mkdir -p $work_dir/zip-files/zone/patch +cp $work_dir/zone_out/*/*.ff $work_dir/zip-files/zone/patch/ # zip iwd_files +mkdir -p $work_dir/launcher-files/iw4x for iwd in "${iwd_files[@]}"; do - pushd $work_dir/release/iw4x/$iwd + pushd $work_dir/zip-files/iw4x/$iwd # Set consistent timestamps for all files find . -exec touch -t 200001010000.00 {} + # Sort files for zipping, -X for deterministic zip find . -name '*' -print0 | LC_ALL=C sort -z | xargs -0 zip -X $iwd.zip - mv $iwd.zip $work_dir/release/iw4x/$iwd.iwd + mv $iwd.zip $work_dir/launcher-files/iw4x/$iwd.iwd popd - rm -r $work_dir/release/iw4x/$iwd + rm -r $work_dir/zip-files/iw4x/$iwd done # add zonebuilder-wrapper -pushd $work_dir/release/ +pushd $work_dir/launcher-files/ curl -L https://github.com/iw4x/zonebuilder-wrapper/releases/latest/download/zonebuilder-i686-pc-windows-msvc.zip -o zonebuilder.zip unzip zonebuilder.zip rm zonebuilder.zip popd -# create release.zip from release dir -pushd $work_dir/release/ +# create release.zip from release.zip dir +pushd $work_dir/zip-files/ zip -r -X release.zip * -mv release.zip $work_dir +mv release.zip $work_dir/launcher-files/ popd # cleanup -rm -r release +rm -r {zip-files,zone_out}