From 921cb05f9672afab53b5d51b4bc2e4c61ccde6e9 Mon Sep 17 00:00:00 2001 From: extrawurst <776816+extrawurst@users.noreply.github.com> Date: Wed, 23 Apr 2025 12:04:55 +0200 Subject: [PATCH] ci on macos (#37) --- .github/actions/steamcmd/action.yml | 30 +++++ .github/workflows/ci.yml | 10 +- .github/workflows/steam_alpha.yml | 170 ++++++++++++++++++++++++++++ .github/workflows/steamos_alpha.yml | 87 -------------- 4 files changed, 208 insertions(+), 89 deletions(-) create mode 100644 .github/actions/steamcmd/action.yml create mode 100644 .github/workflows/steam_alpha.yml delete mode 100644 .github/workflows/steamos_alpha.yml diff --git a/.github/actions/steamcmd/action.yml b/.github/actions/steamcmd/action.yml new file mode 100644 index 0000000..4041192 --- /dev/null +++ b/.github/actions/steamcmd/action.yml @@ -0,0 +1,30 @@ +name: steamcmd +description: install and setup steamcmd +inputs: + config: + description: "steam config as base64 encoded gzipped string" + required: true +runs: + using: "composite" + steps: + - name: Install SteamCMD + shell: bash + run: | + sudo apt-get install lib32gcc-s1 -y + mkdir -p ~/Steam | true + cd ~/Steam + curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf - + chmod +x ~/Steam/ + ~/Steam/steamcmd.sh +help +quit + + - name: Steam Auth + shell: bash + env: + STEAM_CONFIG: ${{ inputs.config }} + STEAM_CONFIG_PATH: ~/.steam/steam/config + run: | + mkdir -p $STEAM_CONFIG_PATH + # Decode the base64 data and save it to the config location + echo "$STEAM_CONFIG" | base64 -d | gunzip > $STEAM_CONFIG_PATH/config.vdf + # Set proper permissions + chmod 755 $STEAM_CONFIG_PATH/config.vdf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e0868e..a200fe3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,10 +7,15 @@ on: jobs: ci: - runs-on: [self-hosted, linux] + strategy: + matrix: + os: [[self-hosted, linux], [self-hosted, macos]] + runs-on: "${{ matrix.os }}" steps: - uses: actions/checkout@v4 - uses: cargo-bins/cargo-binstall@main + + if: runner.os == 'linux' - uses: extractions/setup-just@v1 - uses: dtolnay/rust-toolchain@master with: @@ -18,6 +23,7 @@ jobs: components: clippy, rustfmt - name: "Install and cache dependencies (Linux)" + if: runner.os == 'linux' uses: awalsh128/cache-apt-pkgs-action@latest with: packages: libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev @@ -35,6 +41,6 @@ jobs: run: | cargo build - - name: Lints + - name: Tests run: | cargo test diff --git a/.github/workflows/steam_alpha.yml b/.github/workflows/steam_alpha.yml new file mode 100644 index 0000000..d929c72 --- /dev/null +++ b/.github/workflows/steam_alpha.yml @@ -0,0 +1,170 @@ +name: steam-alpha + +on: + workflow_dispatch: # Enables manual triggers + # pull_request: + +jobs: + steam-macos: + runs-on: [self-hosted, macos] + steps: + - uses: actions/checkout@v4 + - uses: cargo-bins/cargo-binstall@main + - uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + components: clippy, rustfmt + targets: x86_64-apple-darwin, aarch64-apple-darwin + + - uses: leafwing-studios/cargo-cache@v2 + with: + sweep-cache: true + + - name: Build (lipo) + run: | + cargo build --release --target=x86_64-apple-darwin + cargo build --release --target=aarch64-apple-darwin + lipo -create -output target/release/hedz_reloaded target/aarch64-apple-darwin/release/hedz_reloaded target/x86_64-apple-darwin/release/hedz_reloaded + + - name: Archive + run: | + cp target/release/hedz_reloaded ./hedz_reloaded + tar -czf hedz-macos.tar.gz hedz_reloaded + ls -lisah hedz-macos.tar.gz + + - uses: actions/upload-artifact@v4 + with: + name: hedz-macos + path: ./hedz-macos.tar.gz + + steam-macos-deploy: + needs: steam-macos + runs-on: [self-hosted, linux] + steps: + - uses: actions/checkout@v4 + + - name: Download Artifacts + uses: actions/download-artifact@v4 + with: + name: hedz-macos + + - name: Un-Archive + run: | + ls -lisah hedz-macos.tar.gz + tar -xzf hedz-macos.tar.gz + + - name: Assemble App + env: + APP_ROOT: build/macos/src/HEDZReloaded.app/Contents/MacOS + run: | + rm -rf $APP_ROOT/* | true + mkdir -p $APP_ROOT/assets + cp -r assets/* $APP_ROOT/assets + cp hedz_reloaded $APP_ROOT/ + cp build/macos/libsteam_api.dylib $APP_ROOT/ + + - uses: ./.github/actions/steamcmd + with: + config: ${{ secrets.STEAM_CONFIG_VDF_BASE64 }} + + - name: Steam deploy + env: + # needs to be fully qualified path for steamcmd to find it + DEPOT: ${{ github.workspace }}/build/steamos/scripts/hz_macos.vdf + STEAM_USR: ${{ secrets.STEAM_USR }} + run: | + cd build/steamos + ~/Steam/steamcmd.sh +login $STEAM_USR +run_app_build $DEPOT +quit + + - name: Set outputs + id: vars + run: | + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + + - name: Discord notification + uses: appleboy/discord-action@v1.2.0 + with: + webhook_url: ${{ secrets.DISCORD_WEBHOOK }} + message: New macos release (`${{ steps.vars.outputs.branch }}`) [`${{ steps.vars.outputs.sha_short }}`] + + steam-steamos: + runs-on: [self-hosted, linux] + steps: + - uses: actions/checkout@v4 + - uses: cargo-bins/cargo-binstall@main + - uses: extractions/setup-just@v1 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + components: clippy, rustfmt + + - name: "Install and cache dependencies (Linux)" + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev + version: 1.0 + + - uses: leafwing-studios/cargo-cache@v2 + with: + sweep-cache: true + + - name: Build + run: | + cargo build --locked --release --target=x86_64-unknown-linux-gnu + + - name: Archive + run: | + cp target/x86_64-unknown-linux-gnu/release/hedz_reloaded hedz_reloaded + tar -czf steamos.tar.gz hedz_reloaded + + - uses: actions/upload-artifact@v4 + with: + name: steamos.tar.gz + path: ./steamos.tar.gz + + - name: Copy Binary for SteamOS + run: | + mkdir -p build/steamos/content + cp target/x86_64-unknown-linux-gnu/release/hedz_reloaded build/steamos/content/hedz_reloaded + + - name: Install SteamCMD + run: | + sudo apt-get install lib32gcc-s1 -y + mkdir ~/Steam | true + cd ~/Steam + curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf - + chmod +x ~/Steam/ + ~/Steam/steamcmd.sh +help +quit + + - name: Steam Auth + env: + STEAM_CONFIG: ${{ secrets.STEAM_CONFIG_VDF_BASE64 }} + STEAM_CONFIG_PATH: ~/.steam/steam/config + run: | + mkdir -p $STEAM_CONFIG_PATH + # Decode the base64 data and save it to the config location + echo "$STEAM_CONFIG" | base64 -d | gunzip > $STEAM_CONFIG_PATH/config.vdf + # Set proper permissions + chmod 755 $STEAM_CONFIG_PATH/config.vdf + + - name: Steam deploy + env: + # needs to be fully qualified path for steamcmd to find it + DEPOT: ${{ github.workspace }}/build/steamos/scripts/hedz.vdf + STEAM_USR: ${{ secrets.STEAM_USR }} + run: | + cd build/steamos + ~/Steam/steamcmd.sh +login $STEAM_USR +run_app_build $DEPOT +quit + + - name: Set outputs + id: vars + run: | + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + + - name: Discord notification + uses: appleboy/discord-action@v1.2.0 + with: + webhook_url: ${{ secrets.DISCORD_WEBHOOK }} + message: New steamos release (`${{ steps.vars.outputs.branch }}`) [`${{ steps.vars.outputs.sha_short }}`] diff --git a/.github/workflows/steamos_alpha.yml b/.github/workflows/steamos_alpha.yml deleted file mode 100644 index c9c9890..0000000 --- a/.github/workflows/steamos_alpha.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: steamos-alpha - -on: - workflow_dispatch: # Enables manual triggers - # pull_request: - -jobs: - steamos-alpha: - runs-on: [self-hosted, linux] - steps: - - uses: actions/checkout@v4 - - uses: cargo-bins/cargo-binstall@main - - uses: extractions/setup-just@v1 - - uses: dtolnay/rust-toolchain@master - with: - toolchain: stable - components: clippy, rustfmt - - - name: "Install and cache dependencies (Linux)" - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev - version: 1.0 - - - uses: leafwing-studios/cargo-cache@v2 - with: - sweep-cache: true - - - name: Build - run: | - cargo build --locked --release --target=x86_64-unknown-linux-gnu - - - name: Archive - run: | - cp target/x86_64-unknown-linux-gnu/release/hedz_reloaded hedz_reloaded - tar -czf steamos.tar.gz hedz_reloaded - - - uses: actions/upload-artifact@v4 - with: - name: steamos.tar.gz - path: ./steamos.tar.gz - - - name: Copy Binary for SteamOS - run: | - mkdir -p build/steamos/content - cp target/x86_64-unknown-linux-gnu/release/hedz_reloaded build/steamos/content/hedz_reloaded - - - name: Install SteamCMD - run: | - sudo apt-get install lib32gcc-s1 -y - mkdir ~/Steam | true - cd ~/Steam - curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf - - chmod +x ~/Steam/ - ~/Steam/steamcmd.sh +help +quit - - - name: Steam Auth - env: - STEAM_CONFIG: ${{ secrets.STEAM_CONFIG_VDF_BASE64 }} - STEAM_CONFIG_PATH: ~/.steam/steam/config - run: | - mkdir -p $STEAM_CONFIG_PATH - # Decode the base64 data and save it to the config location - echo "$STEAM_CONFIG" | base64 -d | gunzip > $STEAM_CONFIG_PATH/config.vdf - # Set proper permissions - chmod 755 $STEAM_CONFIG_PATH/config.vdf - - - name: Steam deploy - env: - # needs to be fully qualified path for steamcmd to find it - DEPOT: ${{ github.workspace }}/build/steamos/scripts/hedz.vdf - STEAM_USR: ${{ secrets.STEAM_USR }} - run: | - cd build/steamos - ~/Steam/steamcmd.sh +login $STEAM_USR +run_app_build $DEPOT +quit - - - name: Set outputs - id: vars - run: | - echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT - - - name: Discord notification - uses: appleboy/discord-action@v1.2.0 - with: - webhook_url: ${{ secrets.DISCORD_WEBHOOK }} - message: New HEDZ-Reloaded alpha (`${{ steps.vars.outputs.branch }}`) [`${{ steps.vars.outputs.sha_short }}`]