name: Auto Release on: schedule: - cron: '0 0 * * *' workflow_dispatch: jobs: update-and-release: runs-on: ubuntu-latest container: image: nikolaik/python-nodejs:python3.12-nodejs22-slim steps: - name: Install System Dependencies run: | apt-get update && apt-get install -y git - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install Python Dependencies run: pip install --no-cache-dir requests - name: Configure Git run: | git config --global user.name "Gitea Actions" git config --global user.email "actions@gitea.local" # Safe directory is needed when running inside containers git config --global --add safe.directory '*' - name: Run update script env: GITEA_ACTIONS: true run: python main.py || true - name: Check for changes id: git-check run: | if [ -n "$(git status --porcelain discord-quest.js)" ]; then echo "changes=true" >> $GITHUB_OUTPUT else echo "changes=false" >> $GITHUB_OUTPUT fi - name: Process Release if: steps.git-check.outputs.changes == 'true' env: GITEA_TOKEN: ${{ secrets.TOKEN }} GITEA_URL: ${{ secrets.GITEA_URL || github.server_url }} run: | # 1. Commit Changes git add discord-quest.js git commit -m "Update discord-quest.js from upstream gist" git push origin main # 2. Calculate New Tag LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") VERSION=${LATEST_TAG#v} IFS='.' read -r major minor patch <<< "$VERSION" NEW_TAG="v$major.$minor.$((patch + 1))" echo "Bumping version: $LATEST_TAG -> $NEW_TAG" # 3. Push Tag git tag $NEW_TAG git push origin $NEW_TAG # 4. Create Release via API REPO_OWNER=$(echo ${{ github.repository }} | cut -d'/' -f1) REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2) curl -X POST "${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases" \ -H "Authorization: token ${GITEA_TOKEN}" \ -H "Content-Type: application/json" \ -d "{ \"tag_name\": \"$NEW_TAG\", \"name\": \"Release $NEW_TAG\", \"body\": \"Automated release: Updated discord-quest.js\", \"draft\": false, \"prerelease\": false }"