-
-
Notifications
You must be signed in to change notification settings - Fork 12
97 lines (92 loc) · 3.56 KB
/
release.yml
File metadata and controls
97 lines (92 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Release
on:
push:
branches: [main, '*-pre', '*-maint']
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
SERVER_PRESET: 'node-server'
permissions:
contents: read
jobs:
release:
name: Release
if: "!contains(github.event.head_commit.message, 'ci: changeset release')"
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: write
id-token: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: true # release job pushes version changes
- name: Check for changesets
id: changesets
run: |
CHANGESET_FILES=$(ls .changeset/*.md 2>/dev/null | grep -v README.md || true)
if [ -z "$CHANGESET_FILES" ]; then
echo "has_changesets=false" >> "$GITHUB_OUTPUT"
else
echo "has_changesets=true" >> "$GITHUB_OUTPUT"
fi
- name: Start Nx Agents
if: steps.changesets.outputs.has_changesets == 'true'
run: npx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yaml"
- name: Setup Tools
uses: TanStack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3 # main
- name: Run Tests
if: steps.changesets.outputs.has_changesets == 'true'
run: pnpm run test:ci --parallel=3
- name: Stop Nx Agents
if: ${{ always() && steps.changesets.outputs.has_changesets == 'true' }}
run: npx nx-cloud stop-all-agents
- name: Enter Pre-Release Mode
if: "contains(github.ref_name, '-pre') && !hashFiles('.changeset/pre.json')"
run: pnpm changeset pre enter pre
- name: Version Packages
run: pnpm run changeset:version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit and Push Version Changes
id: commit
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
if git commit -m "ci: changeset release"; then
git push origin "HEAD:${GITHUB_REF_NAME}"
echo "committed=true" >> "$GITHUB_OUTPUT"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Determine dist-tag
if: steps.commit.outputs.committed == 'true'
id: dist-tag
run: |
BRANCH="${GITHUB_REF_NAME}"
if [[ "$BRANCH" == *-pre ]]; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
elif [[ "$BRANCH" == *-maint ]]; then
echo "tag=maint" >> "$GITHUB_OUTPUT"
else
echo "latest=true" >> "$GITHUB_OUTPUT"
fi
- name: Publish Packages
if: steps.commit.outputs.committed == 'true'
run: pnpm run changeset:publish ${DIST_TAG_ARG}
env:
DIST_TAG_ARG: ${{ steps.dist-tag.outputs.tag && format('--tag {0}', steps.dist-tag.outputs.tag) }}
- name: Create GitHub Release
if: steps.commit.outputs.committed == 'true'
run: node scripts/create-github-release.mjs ${PRERELEASE_ARG} ${LATEST_ARG}
env:
PRERELEASE_ARG: ${{ steps.dist-tag.outputs.prerelease == 'true' && '--prerelease' }}
LATEST_ARG: ${{ steps.dist-tag.outputs.latest == 'true' && '--latest' }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}