-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (110 loc) · 3.88 KB
/
Copy pathrelease.yml
File metadata and controls
132 lines (110 loc) · 3.88 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Release
on:
push:
branches:
- main
concurrency: release
permissions:
id-token: write
contents: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
changed_dirs: ${{ steps.tag.outputs.changed_dirs }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: '.nvmrc'
- name: Enable Corepack
run: corepack enable
- name: Get Yarn cache path
id: yarn-cache
run: echo "dir=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-${{ runner.os }}-
- run: yarn install --immutable
- name: Check for pending changesets
id: check
run: |
changeset_files=$(find .changeset -name '*.md' ! -name 'README.md' 2>/dev/null || true)
if [ -z "$changeset_files" ]; then
echo "No pending changesets found. Skipping release."
echo "has_changesets=false" >> "$GITHUB_OUTPUT"
else
echo "Pending changesets found:"
echo "$changeset_files"
echo "has_changesets=true" >> "$GITHUB_OUTPUT"
fi
- name: Version packages
if: steps.check.outputs.has_changesets == 'true'
run: yarn version-packages
- name: Check for version changes
if: steps.check.outputs.has_changesets == 'true'
id: diff
run: |
if git diff --quiet; then
echo "No version changes produced. Skipping commit."
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit version bumps
if: steps.diff.outputs.has_changes == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Version Packages"
- name: Push to main
if: steps.diff.outputs.has_changes == 'true'
run: |
git pull --rebase origin main
git push origin main
- name: Tag released versions
if: steps.diff.outputs.has_changes == 'true'
id: tag
run: bash scripts/tag-and-publish.sh
publish:
name: Publish ${{ matrix.dir }}
needs: release
if: needs.release.outputs.changed_dirs != '[]' && needs.release.outputs.changed_dirs != ''
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
dir: ${{ fromJson(needs.release.outputs.changed_dirs) }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: main
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: '.nvmrc'
- name: Enable Corepack
run: corepack enable
- name: Get Yarn cache path
id: yarn-cache
run: echo "dir=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-${{ runner.os }}-
- run: yarn install --immutable
- name: Publish codemod
uses: codemod/publish-action@dd6c8dbc5ceb1a6146feba41481d88b43da50024 # v1
with:
path: ${{ matrix.dir }}