Build AltServer #5601
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build AltServer | |
on: | |
push: | |
workflow_dispatch: | |
inputs: | |
sync_upstream: | |
required: false | |
default: false | |
debug_enabled: | |
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' | |
required: false | |
default: false | |
repository_dispatch: | |
schedule: | |
- cron: "0 */4 * * *" # min hour day week year | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
name: "Check Upstream Updates" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
- name: Check If Need Checking | |
id: needCheck | |
if: ${{ github.event_name == 'schedule' || ( github.event_name == 'workflow_dispatch' && github.event.inputs.sync_upstream ) }} | |
run: | | |
echo "needCheck=1" >> $GITHUB_ENV | |
- name: Check Upstream Version | |
id: check | |
run: | | |
if [[ "$needCheck" == 1 ]]; then | |
echo "Checking changes in upstream_repo..." | |
current_upstream=$(git ls-tree HEAD upstream_repo | awk '{ print $3 }') | |
echo "Current Upstream Commit: $current_upstream" | |
git submodule update --remote -- upstream_repo | |
new_upstream=$( cd upstream_repo; git show -s --format=%H ) | |
echo "New Upstream Commit: $new_upstream" | |
git reset --hard | |
git submodule update --init | |
if [[ "$current_upstream" != "$new_upstream" ]]; then | |
echo "Upstream got new commits, go updating!" | |
echo "::set-output name=updated::1" | |
else | |
echo "Upstream no change~" | |
echo "::set-output name=updated::0" | |
fi | |
else | |
echo "Needn't to check changes, directly return~" | |
echo "::set-output name=updated::0" | |
fi | |
- uses: gautamkrishnar/keepalive-workflow@master | |
with: | |
commit_message: "[proj] keepalive-workflow auto commit" | |
outputs: | |
updated: ${{ steps.check.outputs.updated }} | |
build: | |
needs: [check] | |
strategy: | |
matrix: | |
builder: [ghcr.io/nyamisty/altserver_builder_alpine_armv7, ghcr.io/nyamisty/altserver_builder_alpine_aarch64, ghcr.io/nyamisty/altserver_builder_alpine_amd64, ghcr.io/nyamisty/altserver_builder_alpine_i386] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
- name: Do Submodule Update | |
if: ${{ needs.check.outputs.updated == '1' }} | |
run: | |
git submodule update --remote -- upstream_repo | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Log in to the Container registry | |
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Prepare build | |
run: mkdir /tmp/build_output | |
- name: Build | |
run: | | |
image=${{ matrix.builder }} | |
docker pull $image | |
docker run -v ${PWD}:/workdir -w /workdir $image bash -c 'mkdir build; cd build; make -f ../Makefile -j3' | |
cp build/AltServer-* /tmp/build_output; chmod +x /tmp/build_output/* | |
sudo rm -rf build | |
git clean -fdX | |
- name: Upload to github artifact | |
uses: NyaMisty/upload-artifact-as-is@master | |
with: | |
path: /tmp/build_output | |
release: | |
runs-on: ubuntu-latest | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
needs: [build] | |
name: "release" | |
steps: | |
- name: "Create artifact directory" | |
run: | | |
mkdir -p build_output | |
- name: "Download all artifacts" | |
uses: actions/download-artifact@v2 | |
with: | |
path: build_output | |
- name: "Rearrange artifacts" | |
run: | | |
find build_output | |
mkdir -p build_release | |
mv build_output/*/* build_release | |
ls build_release | |
if [ "$(ls -A build_release)" ]; then exit 0; else exit 1; fi | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: build_release/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
update_submodule: | |
runs-on: ubuntu-latest | |
needs: [check, build] | |
if: ${{ needs.check.outputs.updated == '1' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
- name: Commit Submodule Update | |
run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git submodule update --remote -- upstream_repo | |
git commit -m "[server] Sync Upstream Repo commit" upstream_repo | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |