From 28cb202d2bf567f406be2ed75208241d50dc0634 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Wed, 31 May 2023 23:22:54 -0400 Subject: [PATCH] Update GitHub actions --- .github/workflows/build.yml | 1 - .github/workflows/check_code.yml | 35 +++++++++++++++- .github/workflows/handbook.yml | 8 +++- .github/workflows/language_lint.yml | 1 + .github/workflows/lint_commit.yml | 63 ----------------------------- 5 files changed, 40 insertions(+), 68 deletions(-) delete mode 100644 .github/workflows/lint_commit.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 002e37d07..eba9a3597 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,6 @@ on: - "stable" - "development" - "unstable" - - "unstable-quests" pull_request: paths: - "**.java" diff --git a/.github/workflows/check_code.yml b/.github/workflows/check_code.yml index 565fd0eeb..d255b3412 100644 --- a/.github/workflows/check_code.yml +++ b/.github/workflows/check_code.yml @@ -7,6 +7,7 @@ on: - "src/main/**.java" - "**.json" branches: + - "development" - "unstable" jobs: @@ -17,6 +18,10 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch - name: Setup Java uses: actions/setup-java@v3 with: @@ -38,10 +43,36 @@ jobs: - run: git config --global user.name "github-actions" - run: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - run: git stash - - run: git checkout unstable && git pull + - run: git checkout ${{ steps.extract_branch.outputs.branch }} && git pull - run: git stash pop || true - name: Commit Code Changes run: git add -u && git commit -m 'Format code [skip actions]' || true - name: Push Code Changes - run: git push --set-upstream --force origin unstable + run: git push --set-upstream --force origin ${{ steps.extract_branch.outputs.branch }} + + Update-Languages: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + - name: Update Languages + run: python scripts/manage_languages.py -u + + - run: git config --global user.name "github-actions" + - run: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + - run: git stash + - run: git checkout ${{ steps.extract_branch.outputs.branch }} && git pull + - run: git stash pop || true + + - name: Commit any language changes + run: git add -u && git commit -m 'Update languages [skip actions]' || true + - name: Push language changes + run: git push --set-upstream --force origin ${{ steps.extract_branch.outputs.branch }} diff --git a/.github/workflows/handbook.yml b/.github/workflows/handbook.yml index 72dc1f3bc..3e73ba429 100644 --- a/.github/workflows/handbook.yml +++ b/.github/workflows/handbook.yml @@ -22,6 +22,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch - name: Setup Node uses: actions/setup-node@v2 with: @@ -45,14 +49,14 @@ jobs: - run: git config --global user.name "github-actions" - run: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - run: git stash - - run: git checkout unstable && git pull + - run: git checkout ${{ steps.extract_branch.outputs.branch }} && git pull - run: git stash pop || true - name: Commit changes if: ${{ github.event_name == 'push' }} run: git add -u && git commit -m "Lint Code [skip actions]" || true - name: Push changes if: ${{ github.event_name == 'push' }} - run: git push --set-upstream --force origin unstable + run: git push --set-upstream --force origin ${{ steps.extract_branch.outputs.branch }} Build-Handbook: runs-on: ubuntu-latest diff --git a/.github/workflows/language_lint.yml b/.github/workflows/language_lint.yml index b0f176ad6..cdf23cd4f 100644 --- a/.github/workflows/language_lint.yml +++ b/.github/workflows/language_lint.yml @@ -10,6 +10,7 @@ on: branches: - "stable" - "development" + - "unstable" pull_request: paths: - ".github/workflows/**" diff --git a/.github/workflows/lint_commit.yml b/.github/workflows/lint_commit.yml deleted file mode 100644 index c1abd8538..000000000 --- a/.github/workflows/lint_commit.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: "Lint whitespace and languages" -on: - workflow_dispatch: ~ - push: - paths: - - ".github/workflows/**" - - "src/main/**.java" - - "**.json" - - "build.gradle" - - "scripts/format_whitespace.py" - - "scripts/manage_languages.py" - branches: - - "development" -jobs: - Make-Lint-Commits: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Run Whitespace Linter - run: python scripts/format_whitespace.py - - run: git config --global user.name "github-actions" - - run: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - - run: git stash - - run: git checkout LintRatchet - # - run: git merge development - - run: git reset --hard development - - run: git stash pop || true - - - name: Commit any whitespace changes - run: git add -u && git commit -m 'Fix whitespace [skip actions]' || true - - - name: Update Languages - run: python scripts/manage_languages.py -u - - - name: Commit any language changes - run: git add -u && git commit -m 'Update languages [skip actions]' || true - - - name: Bump version to a release - # a.b.c-dev -> a.b.c - # If any breaking changes, a.b.c-dev -> a.(b+1).0 - run: | - export BREAKING=`git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%s" --grep="BREAKING"` - if [[ $BREAKING ]]; then export NEXT_VERSION=`sed -nr "s/^version = '(.*\.)([0-9]+)\.[0-9]+(-dev)?'"'/echo "\1$((\2+1)).0"/ep' build.gradle`; else export NEXT_VERSION=`sed -nr "s/^version = '(.*)-dev'/\1/p" build.gradle`; fi - export CHANGELOG=`git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%s"` - perl -pi -e "s/version = '.*'/version = '$NEXT_VERSION'/g" build.gradle - git add build.gradle && git commit -m "Version $NEXT_VERSION" -m "$CHANGELOG" - - - name: Bump version to next dev - # a.b.c -> a.b.(c+1)-dev - run: | - export NEXT_VERSION=`sed -nr "s/^version = '(.*)([0-9]+)'"'/echo "\1$((\2+1))-dev"/ep' build.gradle` - perl -pi -e "s/version = '.*'/version = '$NEXT_VERSION'/g" build.gradle - git add build.gradle && git commit -m "Version $NEXT_VERSION [skip actions]" - - - name: Force-push changes to LintRatchet - run: git push --set-upstream --force origin LintRatchet