diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..521efc9 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,16 @@ +name: Publish + +on: + pull_request: + branches: [main] + types: [closed] + +jobs: + version-bump: + if: startsWith(github.event.pull_request.title, 'v') && github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 \ No newline at end of file diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml new file mode 100644 index 0000000..436cd48 --- /dev/null +++ b/.github/workflows/version.yml @@ -0,0 +1,52 @@ +name: Version Bump + +on: + pull_request: + branches: [main] + types: [opened] + +jobs: + version-bump: + if: startsWith(github.event.pull_request.title, 'v') + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Extract version from PR title + id: extract-version + run: | + if [[ "${{ github.event.pull_request.title }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "version=${BASH_REMATCH[0]}" >> $GITHUB_OUTPUT + else + echo "❌ No valid version found in PR title" + exit 1 + fi + + - name: Bump version + run: | + VERSION=${{ steps.extract-version.outputs.version }} + npm version $VERSION --no-git-tag-version + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Commit & Push + run: | + VERSION=${{ steps.extract-version.outputs.version }} + git add package.json package-lock.json + git commit -m "chore: bump version to v$VERSION" + git push https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/koderpark/ani-relayer.git main --follow-tags