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

Commit

Permalink
ci: updated workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
AH-dark committed Sep 22, 2024
1 parent 8a0d319 commit df0cbe7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
18 changes: 4 additions & 14 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,16 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get latest git release
id: get-latest-release
run: |
LATEST_RELEASE=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "release=$LATEST_RELEASE" >> $GITHUB_OUTPUT
- name: Install dependencies
run: |
sudo apt install -y jq curl
- name: Get latest WordPress version
id: get-wordpress-version
run: |
LATEST_VERSION=$(curl -s https://api.wordpress.org/core/version-check/1.7/ | jq -r '.offers[0].current')
echo "Latest WordPress version is $LATEST_VERSION"
echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT
python -m pip install -r requirements.txt
python latest-version.py >> $GITHUB_OUTPUT
git push
- name: Create release
uses: softprops/action-gh-release@v2
if: steps.get-latest-release.outputs.release != steps.get-wordpress-version.outputs.version
if: steps.get-wordpress-version.outputs.is_update == 'true'
with:
tag_name: ${{ steps.get-wordpress-version.outputs.version }}
name: ${{ steps.get-wordpress-version.outputs.version }}
Expand Down
13 changes: 9 additions & 4 deletions latest-version.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,26 @@ def compare_current_version(latest_version):

def git_commit(version):
# Add changes to the staging area
subprocess.run(["git", "add", ".current-version"], check=True)
subprocess.run(
["git", "add", ".current-version"],
check=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)

# Commit the changes with the provided commit message
subprocess.run(
["git", "commit", "-m", f"Update WordPress to version {version}"],
check=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)

print("Commit successful!")


if __name__ == "__main__":
version = get_latest_version()
is_update = compare_current_version(version)
if is_update:
git_commit(version)

print(is_update)
print(f"version={version}\nis_update={is_update}")

0 comments on commit df0cbe7

Please sign in to comment.