Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
build: change tooling to match TR1X
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Apr 13, 2024
1 parent 36c166c commit 9a24d55
Show file tree
Hide file tree
Showing 23 changed files with 529 additions and 226 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@ jobs:
publish_docker_image:
name: Build Docker toolchain
runs-on: ubuntu-latest
strategy:
matrix:
include:
- platform: win
steps:
- name: 'Login to Docker Hub'
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: 'Checkout code'
uses: actions/checkout@v2
with:
path: .
fetch-tags: true
- name: Install dependencies
uses: taiki-e/install-action@just

- name: Checkout code
uses: actions/checkout@v4

- name: 'Build Docker image'
- name: Build Docker image (${{ matrix.platform }})
run: |
docker build -t "rrdash/tr2x:latest" . -f docker/game-win/Dockerfile
docker push "rrdash/tr2x:latest"
just image-${{ matrix.platform }}
just push-image-${{ matrix.platform }}
66 changes: 0 additions & 66 deletions .github/workflows/build_game_win.yml

This file was deleted.

54 changes: 39 additions & 15 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,50 @@ jobs:
uses: actions/checkout@v2
with:
path: .
fetch-tags: true
fetch-depth: 0

- name: 'Install dependencies'
- name: Check JSON files validity
shell: python
run: |
import json
from pathlib import Path
errors = False
for path in Path('.').rglob('**/*.json'):
try:
json.loads(path.read_text())
except json.JSONDecodeError as ex:
print(f'Malformed JSON in {path}: {ex}')
errors = True
if errors:
exit(1)
- name: Install dependencies
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main' | sudo tee -a /etc/apt/sources.list
echo 'deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main' | sudo tee -a /etc/apt/sources.list
echo 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' | sudo tee -a /etc/apt/sources.list
echo 'deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt-get install -y clang-format-12 iwyu
sudo ln -s /usr/bin/clang-format-12 /usr/local/bin/clang-format
sudo apt-get install -y make python3-pip
sudo python3 -m pip install pyjson5
sudo apt-get install -y clang-format-18 iwyu
sudo snap install --edge --classic just
sudo ln -s /usr/bin/clang-format-18 /usr/local/bin/clang-format
sudo apt-get install -y python3-pip
sudo python3 -m pip install pyjson5 pre-commit
- name: 'Check imports'
- name: Check formatted code differences
run: |
git add -A
python3 tools/sort_imports
git diff --exit-code || ( echo 'Please run `make imports` and commit the changes.'; exit 1 )
just lint-format || /bin/true
git diff --exit-code || (
clang-format --version
echo 'Please run `just lint` and commit the changes.'
exit 1
)
- name: 'Check formatted code differences'
- name: Check imports
run: |
make lint
git diff --exit-code || ( echo 'Please run `make lint` and commit the changes.'; exit 1 )
git add -A
just lint-imports
git diff --exit-code || (
include-what-you-use --version
echo 'Please run `just lint` and commit the changes.'
exit 1
)
24 changes: 9 additions & 15 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
name: Publish a prerelease
name: Publish a pre-release

permissions:
contents: write

on:
push:
branch: develop
branches:
- develop

jobs:
tag_latest:
name: 'Tag the repository'
runs-on: ubuntu-latest
steps:
- name: 'Checkout code'
uses: actions/checkout@v3

- name: 'Update the tag'
uses: EndBug/latest-tag@latest

publish_prerelease:
name: 'Create a prerelease'
needs:
- tag_latest
uses: ./.github/workflows/release.yml
if: |
github.ref == 'refs/heads/develop' &&
vars.RELEASE_ENABLE == 'true'
with:
release_name: 'Development snapshot'
draft: false
prerelease: true
tag_name: latest
tag_name: 'latest'
let_mac_fail: true
secrets: inherit
144 changes: 100 additions & 44 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,82 +7,138 @@ on:
push:
branch: stable
tags:
- 'v?[0-9]*'
- "v?[0-9]*"

workflow_call:
inputs:
release_name:
description: 'Release name'
draft:
type: boolean
description: "Draft"
required: true
default: 'Release ${{ github.ref_name }}'
default: false
prerelease:
type: boolean
description: "Prerelease"
required: true
default: false
release_name:
type: string
description: "Release name"
required: true
default: "Release ${{ github.ref_name }}"
tag_name:
description: 'Tag name'
required: false
default: '${{ github.ref }}'
type: string
description: "Tag name"
required: false
default: github.ref_name

workflow_dispatch:
inputs:
draft:
description: 'Draft'
description: "Draft"
required: true
default: false
type: boolean
default: false
prerelease:
description: 'Prerelease'
description: "Prerelease"
required: true
type: boolean
default: false
release_name:
description: "Release name"
required: true
type: string
default: "Release name"
tag_name:
description: "Tag name"
required: false
type: string
default: github.ref_Name

jobs:
package_multiplatform:
name: Build release assets
runs-on: ubuntu-latest
if: vars.RELEASE_ENABLE == 'true'
strategy:
matrix:
include:
- platform: win
just_target: package-win
steps:
- name: Install dependencies
uses: taiki-e/install-action@just

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Package asset (${{ matrix.platform }})
run: just ${{ matrix.just_target }}

- name: Upload the artifact
uses: actions/upload-artifact@v4
with:
name: packaged_asset-${{ matrix.platform }}
path: |
*.zip
*.exe
publish_release:
name: 'Create a GitHub release'
if: vars.RELEASE_ENABLE == 'true'
name: Create a GitHub release
runs-on: ubuntu-latest
needs:
- package_game_win
- package_multiplatform

steps:
- name: 'Checkout code'
uses: actions/checkout@v3
with:
path: .
fetch-tags: true
- name: "Install dependencies"
uses: taiki-e/install-action@just

- name: 'Download built assets'
uses: actions/download-artifact@v1
- name: "Checkout code"
uses: actions/checkout@v4

- name: "Download built game assets"
uses: actions/download-artifact@v4
with:
name: game_win_zip
path: artifacts/
merge-multiple: true

- name: 'Prepare the changelog'
id: prepare_changelog
uses: ./.github/actions/prepare_changelog
- name: "Generate changelog"
run: |
just output-current-changelog > _changes.txt
- name: 'Get version'
id: get_version
uses: ./.github/actions/get_version
- name: "Get information on the latest pre-release"
if: ${{ inputs.prerelease == true || inputs.prerelease == 'true' }}
id: last_release
uses: InsonusK/[email protected]
with:
myToken: ${{ github.token }}
exclude_types: "draft|release"

- 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: 'Mark the pre-release as latest'
if: ${{ inputs.prerelease == true || inputs.prerelease == 'true' }}
uses: EndBug/latest-tag@latest

- name: 'Delete old release assets'
- name: "Delete old pre-release assets"
if: ${{ inputs.prerelease == true || inputs.prerelease == 'true' }}
uses: mknejp/delete-release-assets@v1
continue-on-error: true
with:
token: ${{ github.token }}
tag: ${{ inputs.tag_name }}
assets: '*.*'
tag: ${{ steps.last_release.outputs.tag_name }}
assets: "*.*"

- name: 'Publish the release'
uses: softprops/action-gh-release@v1
- name: "Publish a release"
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ inputs.release_name }}
body_path: artifacts/changes.txt
draft: ${{ inputs.draft }}
prerelease: ${{ inputs.prerelease }}
fail_on_unmatched_files: true
tag_name: ${{ inputs.tag_name }}
body_path: _changes.txt
draft: ${{ inputs.draft == true || inputs.draft == 'true' }}
prerelease: ${{ inputs.prerelease == true || inputs.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)'
uses: ./.github/workflows/build_game_win.yml
artifacts/*
Loading

0 comments on commit 9a24d55

Please sign in to comment.