Release Tracking #3391
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Welcome | |
on: | |
pull_request: | |
jobs: | |
release-template: | |
if: ${{ github.head_ref == 'changeset-release/main' || github.head_ref == 'changeset-release/next_major' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.x | |
cache: 'npm' | |
- name: Get or Create Comment | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const fs = require('fs') | |
const body = await fs.readFileSync('.github/release_template.md', 'utf8') | |
const result = await github.rest.issues.listComments({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo | |
}); | |
console.log(result.data) | |
const primerComments = result.data.filter(c => c.user.login == 'github-actions[bot]') | |
if (!primerComments.length) { | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: body.replace('{{PR_AUTHOR}}', context.payload.sender.login) | |
}) | |
} | |
bundle-stats: | |
needs: release-template | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
- run: npm ci | |
- run: npm run pretest | |
- name: Reporting bundle sizes | |
uses: primer/comment-token-update@main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_USER: github-actions[bot] | |
with: | |
comment-token: 'bundle_table' | |
script: | | |
bundles=$(script/bundle-size-report.js) | |
if [[ $bundles ]]; then | |
echo "### Bundles with a size change since [latest release](https://github.com/primer/css/releases/latest)" | |
echo "" | |
echo "$bundles" | |
fi | |
- name: Reporting selector diffs | |
uses: primer/comment-token-update@main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_USER: github-actions[bot] | |
with: | |
comment-token: 'diff_report' | |
script: | | |
diff=$(script/selector-diff-report) | |
if [[ $diff ]]; then | |
echo "### Selectors added/removed since [latest release](https://github.com/primer/css/releases/latest)" | |
echo "" | |
echo "\`\`\`diff" | |
echo "$diff" | |
echo "\`\`\`" | |
fi | |
label-release: | |
if: ${{ github.repository == 'primer/css' }} | |
name: Semantic Version Label | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/github-script@v7 | |
id: version-result | |
with: | |
github-token: "${{ secrets.GITHUB_TOKEN }}" | |
result-encoding: string | |
script: | | |
const diff_url = context.payload.pull_request.diff_url | |
const result = await github.request(diff_url) | |
const match = [...result.data.matchAll(/^\+['"]@primer\/css['"]:\s(patch|minor|major)/mg)] | |
if (match && match[0]) { | |
return match[0][1] | |
} | |
- uses: actions/github-script@v7 | |
env: | |
RELEASE: ${{ steps.version-result.outputs.result }} | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
if (process.env.RELEASE == 'undefined') { return } | |
const issue = await github.rest.issues.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number | |
}) | |
const currentLabels = issue.data.labels.map( l => l.name) | |
const newLabel = `${process.env.RELEASE} release` | |
if (!currentLabels.includes(newLabel)) { | |
const otherReleaseLabels = currentLabels.filter( l => l.endsWith(' release')) | |
if (otherReleaseLabels.length) { | |
github.rest.issues.removeLabel({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: [otherReleaseLabels] | |
}) | |
} | |
github.rest.issues.addLabels({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: [newLabel] | |
}) | |
} |