diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..87b0bf11 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,123 @@ +name: Release + +on: + push: + tags: '*' + +env: + CARGO_TERM_COLOR: always + CMAKE_CONFIG: RelWithDebInfo + +jobs: + create_release: + runs-on: ubuntu-24.04 + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + git_tag: ${{ steps.get-git-tag.outputs.name }} + + steps: + - name: Get Git tag + id: get-git-tag + run: echo "name=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + + - id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.get-git-tag.outputs.name }} + release_name: libloot v${{ steps.get-git-tag.outputs.name }} + body: | + Requires Windows 7 or later, the MSVC 2022 [x86](https://aka.ms/vs/17/release/vc_redist.x86.exe) or [x64](https://aka.ms/vs/17/release/vc_redist.x64.exe) redistributable for 32-bit and 64-bit builds respectively, and [7-Zip](http://www.7-zip.org/) to extract the archives. + + ## Change Logs + - [API](https://loot-api.readthedocs.io/en/latest/api/changelog.html) + - [Metadata Syntax](https://loot-api.readthedocs.io/en/latest/metadata/changelog.html) + + windows: + runs-on: windows-2025 + needs: create_release + + strategy: + matrix: + target: + - platform: Win32 + triple: i686-pc-windows-msvc + + - platform: x64 + triple: x86_64-pc-windows-msvc + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Cache cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-${{ matrix.target.platform }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Install Rust i686-pc-windows-msvc target + run: rustup target add i686-pc-windows-msvc + if: matrix.target.platform == 'Win32' + + - name: Set LIBLOOT_REVISION + shell: bash + run: echo "LIBLOOT_REVISION=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV" + + - name: Run CMake + working-directory: cpp + run: | + cmake -G "Visual Studio 17 2022" ` + -A ${{ matrix.target.platform }} ` + -DCPACK_PACKAGE_VERSION="${{ needs.create_release.outputs.git_tag }}" ` + -DRUST_TARGET="${{ matrix.target.triple }}" ` + -B build + cmake --build build --parallel --config ${{ env.CMAKE_CONFIG }} + + - uses: actions/setup-python@v5 + with: + python-version: '3.13' + + - name: Install packages for building docs + working-directory: cpp + run: | + nuget install doxygen -Version 1.8.14 + echo "${{ github.workspace }}\Doxygen.1.8.14\tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + python -m pip install -r docs/requirements.txt + + - name: Build docs + working-directory: cpp + run: sphinx-build -b html docs build\docs\html + + - name: Build archive + id: build-archive + shell: bash + working-directory: cpp/build + run: | + cpack -C ${{ env.CMAKE_CONFIG }} + + if [[ "${{ matrix.target.platform }}" == "Win32" ]] + then + PLATFORM=win32 + else + PLATFORM=win64 + fi + + echo "filename=libloot-${{ needs.create_release.outputs.git_tag }}-${PLATFORM}.7z" >> "$GITHUB_OUTPUT" + + - name: Upload Archive + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + asset_path: cpp/build/package/${{ steps.build-archive.outputs.filename }} + asset_name: ${{ steps.build-archive.outputs.filename }} + asset_content_type: application/x-7z-compressed