From 1d09e52bffdafdd0673dcfbd1a9655e6aaa9cb74 Mon Sep 17 00:00:00 2001 From: Darnell Andries Date: Tue, 28 Jan 2025 19:01:23 -0800 Subject: [PATCH] Create main.yml --- .github/workflows/main.yml | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..33e50f6 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,58 @@ +name: Update Crate + +on: + schedule: + - cron: '0 0 1 */3 *' + +jobs: + update-crate: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Run generate script + run: | + chmod +x ./generate.sh + ./generate.sh + + - name: Check for changes + id: git-check + run: | + git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT + + - name: Bump Cargo.toml minor version + if: steps.git-check.outputs.changes == 'true' + run: | + # Read current version + current_version=$(grep -m1 'version =' Cargo.toml | sed 's/.*= "//' | sed 's/"//') + + # Split version into major, minor, patch + IFS='.' read -r major minor patch <<< "$current_version" + + # Increment minor version + new_minor=$((minor + 1)) + new_version="$major.$new_minor.0" + + # Update Cargo.toml + sed -i "s/^version = \".*\"/version = \"$new_version\"/" Cargo.toml + + echo "Version bumped from $current_version to $new_version" + + - name: Create Pull Request + if: steps.git-check.outputs.changes == 'true' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config user.name "GitHub Actions Bot" + git config user.email "<>" + git add . + git commit -m "Update crate and bump version" + git push origin HEAD:update-crate + gh pr create --title "Update crate" --body "This PR updates the crate and bumps the minor version." --base main --head update-crate + + - name: Check PR status + if: steps.git-check.outputs.changes == 'true' + run: | + echo "Pull Request 'Update crate' created successfully!"