From 2d09931d40ad419747b55a5d0a8dd4be953585d3 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Tue, 31 Oct 2023 15:36:25 +0100 Subject: [PATCH] build: add development builds --- .github/actions/build_game_win.yml | 23 +++++++ .github/actions/get_version.yml | 17 +++++ .github/actions/package_game_win.yml | 23 +++++++ .github/actions/prepare_changelog.yml | 26 ++++++++ .github/workflows/prerelease.yml | 58 ++++++++++++++++ .github/workflows/release.yml | 96 ++++++--------------------- 6 files changed, 166 insertions(+), 77 deletions(-) create mode 100644 .github/actions/build_game_win.yml create mode 100644 .github/actions/get_version.yml create mode 100644 .github/actions/package_game_win.yml create mode 100644 .github/actions/prepare_changelog.yml create mode 100644 .github/workflows/prerelease.yml diff --git a/.github/actions/build_game_win.yml b/.github/actions/build_game_win.yml new file mode 100644 index 00000000..048c4778 --- /dev/null +++ b/.github/actions/build_game_win.yml @@ -0,0 +1,23 @@ +name: 'Build the game (Windows)' +runs: + using: 'composite' + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + path: . + fetch-depth: 0 + + - name: Install dependencies + run: | + echo "$GITHUB_CONTEXT" + sudo apt-get update + sudo apt-get install -y make moby-engine moby-cli + + - name: Build the game + run: | + make clean release + mkdir out/ + cp build/win/*.exe out/ + cp build/win/*.dll out/ + cp -r bin/* out/ diff --git a/.github/actions/get_version.yml b/.github/actions/get_version.yml new file mode 100644 index 00000000..f16d2632 --- /dev/null +++ b/.github/actions/get_version.yml @@ -0,0 +1,17 @@ +name: 'Get the current version' +runs: + outputs: + version: + description: 'Repository version' + value: '${{ steps.get_version.outputs.VERSION }}' + using: 'composite' + steps: + - name: 'Checkout code' + uses: 'actions/checkout@v3' + with: + path: . + fetch-depth: 0 + + - name: 'Extract tag name' + id: 'get_version' + run: 'echo {VERSION}={$(git describe --always --abbrev=7 --tags)}' >> $GITHUB_OUTPUT diff --git a/.github/actions/package_game_win.yml b/.github/actions/package_game_win.yml new file mode 100644 index 00000000..250dfb6d --- /dev/null +++ b/.github/actions/package_game_win.yml @@ -0,0 +1,23 @@ +name: 'Package the game (Windows)' +runs: + using: composite + steps: + - name: 'Build the game' + uses: ./.github/actions/build_game_win.yml + + - name: 'Download built game assets' + uses: actions/download-artifact@v1 + with: + path: artifacts/ + name: game-win + + - name: 'Install dependencies' + run: | + sudo apt-get update + sudo apt-get install -y make p7zip-full + + - name: 'Package the game' + run: | + mkdir out + cd artifacts + 7z a ../out/game-win.zip * diff --git a/.github/actions/prepare_changelog.yml b/.github/actions/prepare_changelog.yml new file mode 100644 index 00000000..19580634 --- /dev/null +++ b/.github/actions/prepare_changelog.yml @@ -0,0 +1,26 @@ +name: 'Package the game (Windows)' +runs: + using: 'composite' + outputs: + version: + description: 'Changelog' + value: '${{ steps.prepare_changelog.outputs.CHANGELOG }}' + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + path: . + fetch-depth: 0 + + - name: Prepare changelog + id: prepare_changelog + run: | + python3 -c ''' + import re + from pathlib import Path + sections = [s for s in Path("CHANGELOG.md").read_text().split("\n\n") if re.search("- \w", s)] + if sections: + section = sections[0] + print("\n".join(line for line in section.splitlines() if not line.startswith("#"))) + ''' > /tmp/changes.txt + echo {VERSION}={$(cat /tmp/changes.txt)}' >> $GITHUB_OUTPUT diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml new file mode 100644 index 00000000..16ad6696 --- /dev/null +++ b/.github/workflows/prerelease.yml @@ -0,0 +1,58 @@ +name: Publish a new release + +permissions: + contents: write + +on: + push: + branch: develop + +jobs: + publish_prerelease: + name: 'Create a GitHub prerelease' + runs-on: ubuntu-latest + needs: + - package_game_win + steps: + - name: 'Download built assets' + uses: actions/download-artifact@v1 + with: + path: artifacts/ + + - name: 'Prepare the changelog' + id: prepare_changelog + uses: ./.github/actions/prepare_changelog.yml + + - name: 'Get version' + id: get_version + uses: ./.github/actions/get_version.yml + + - name: 'Prepare for the release' + run: | + echo ${{steps.prepare_changelog.outputs.CHANGELOG }} >artifacts/changes.txt + mv artifacts/game-win.zip artifacts/TR2X-${{ steps.get_version.outputs.VERSION }}-Windows.zip + + - name: 'Publish the release' + uses: softprops/action-gh-release@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + name: 'Release ${{ github.ref_name }}' + body_path: artifacts/changes.txt + draft: false + prerelease: true + fail_on_unmatched_files: true + files: | + artifacts/TR2X-${{ steps.get_version.outputs.VERSION }}-Windows.zip + + package_game_win: + name: 'Package the game (Windows)' + runs-on: ubuntu-latest + steps: + - name: 'Package the game' + uses: ./.github/actions/package_game_win.yml + + - name: 'Upload the artifact' + uses: actions/upload-artifact@v1 + with: + name: 'game-win-all' + path: out/game-win.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index faa21eed..7cda877d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,3 @@ - name: Publish a new release permissions: @@ -35,46 +34,34 @@ on: jobs: publish_release: - name: Create a GitHub release + name: 'Create a GitHub release' runs-on: ubuntu-latest - needs: [package_game_win] + needs: + - package_game_win steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - path: . - fetch-depth: 0 - - - name: Download built game asset + - name: 'Download built assets' uses: actions/download-artifact@v1 with: path: artifacts/ - name: game-win-all - - name: Extract tag name + - name: 'Prepare the changelog' + id: prepare_changelog + uses: ./.github/actions/prepare_changelog.yml + + - name: 'Get version' id: get_version - run: echo ::set-output name=VERSION::$(git describe --abbrev=7 --tags) + uses: ./.github/actions/get_version.yml - - name: Rename assets + - name: 'Prepare for the release' run: | + echo ${{steps.prepare_changelog.outputs.CHANGELOG }} >artifacts/changes.txt mv artifacts/game-win.zip artifacts/TR2X-${{ steps.get_version.outputs.VERSION }}-Windows.zip - - name: Generate Changelog - run: | - python3 -c ''' - import re - from pathlib import Path - sections = [s for s in Path("CHANGELOG.md").read_text().split("\n\n") if re.search("- \w", s)] - if sections: - section = sections[0] - print("\n".join(line for line in section.splitlines() if not line.startswith("#"))) - ''' > artifacts/changes.txt - - - name: Release + - name: 'Publish the release' uses: softprops/action-gh-release@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - name: Release ${{ github.ref_name }} + name: 'Release ${{ github.ref_name }}' body_path: artifacts/changes.txt draft: ${{ inputs.draft }} prerelease: ${{ inputs.prerelease }} @@ -82,60 +69,15 @@ jobs: files: | artifacts/TR2X-${{ steps.get_version.outputs.VERSION }}-Windows.zip - build_game_win: - name: Build the game (Windows) - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - path: . - fetch-depth: 0 - - - name: Install dependencies - run: | - echo "$GITHUB_CONTEXT" - sudo apt-get update - sudo apt-get install -y make moby-engine moby-cli - - - name: Build the game - run: | - make clean release - mkdir out/ - cp build/win/*.exe out/ - cp build/win/*.dll out/ - cp -r bin/* out/ - - - name: Upload the artifact - uses: actions/upload-artifact@v1 - with: - name: game-win - path: out/ - package_game_win: - name: Package the game (Windows) - needs: [build_game_win] + name: 'Package the game (Windows)' runs-on: ubuntu-latest steps: - - name: Download built game assets - uses: actions/download-artifact@v1 - with: - path: artifacts/ - name: game-win - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y make p7zip-full - - - name: Package the game - run: | - mkdir out - cd artifacts - 7z a ../out/game-win.zip * + - name: 'Package the game' + uses: ./.github/actions/package_game_win.yml - - name: Upload the artifact + - name: 'Upload the artifact' uses: actions/upload-artifact@v1 with: - name: game-win-all + name: 'game-win-all' path: out/game-win.zip