Skip to content

Commit 8c4e805

Browse files
authored
GitHub CI and release workflow (#4)
1 parent 687d046 commit 8c4e805

7 files changed

Lines changed: 2188 additions & 11 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: CI and Release
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
types: [opened, synchronize, reopened]
7+
push:
8+
branches: [main]
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
contents: write
17+
18+
jobs:
19+
test-and-release:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Check version tag does not exist
26+
run: |
27+
VERSION=$(node -p "require('./package.json').version")
28+
if git ls-remote --tags origin | grep -q "refs/tags/v${VERSION}$"; then
29+
echo "::error::Tag v${VERSION} already exists. Bump version in package.json first."
30+
exit 1
31+
fi
32+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: '20'
38+
cache: 'npm'
39+
40+
- name: Install dependencies
41+
run: npm ci
42+
43+
- name: Run tests
44+
run: npm test
45+
46+
- name: Create version tags
47+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
48+
run: |
49+
VERSION="${{ env.VERSION }}"
50+
MAJOR=$(echo "$VERSION" | cut -d. -f1)
51+
52+
git config user.name "github-actions[bot]"
53+
git config user.email "github-actions[bot]@users.noreply.github.com"
54+
55+
git tag "v${VERSION}"
56+
git tag -f "v${MAJOR}"
57+
git push origin "v${VERSION}" "+v${MAJOR}"
58+
59+
- name: Write job summary
60+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
61+
run: |
62+
VERSION="${{ env.VERSION }}"
63+
MAJOR=$(echo "$VERSION" | cut -d. -f1)
64+
SHA="${{ github.sha }}"
65+
66+
cat >> $GITHUB_STEP_SUMMARY << EOF
67+
## Release Summary
68+
69+
| Item | Value |
70+
|--------------|----------------------------------|
71+
| Version | \`${VERSION}\` |
72+
| Commit | \`${SHA:0:7}\` |
73+
| Tags Created | \`v${VERSION}\`, \`v${MAJOR}\` |
74+
75+
Users can reference this action as:
76+
- \`uses: boldtrail/pr-integration-action@v${VERSION}\` - exact version
77+
- \`uses: boldtrail/pr-integration-action@v${MAJOR}\` - latest v${MAJOR}.x.x
78+
EOF

AGENTS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ A GitHub Action that automatically integrates approved Pull Requests into a stag
66

77
- **Run locally:** `npm start` (runs `node src/main.js`, requires GitHub Action environment variables)
88
- **Install dependencies:** `npm install`
9+
- **Run tests:** `npm test` (vitest, tests in `test/`)
910
- **Manual test:** Trigger via GitHub Actions workflow dispatch (`.github/workflows/test_workflow.yml`)
10-
- No test suite, linter, or build step is configured.
11+
- No linter or build step is configured.
1112

1213
## Architecture
1314

@@ -61,7 +62,7 @@ Inputs: `repository`, `github_token`, `token_with_workflow_scope`, `master_branc
6162

6263
Output: `haveUpdates` — "yes" or "no"
6364

64-
Runtime: node16 (per action.yml)
65+
Runtime: node20 (per action.yml)
6566

6667

6768
## Formatting

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ outputs:
4040
description: Indicates whether any new or updated PRs were integrated. Values 'yes', 'no'
4141

4242
runs:
43-
using: 'node16'
43+
using: 'node20'
4444
main: 'entrypoint.js'

0 commit comments

Comments
 (0)