-
Notifications
You must be signed in to change notification settings - Fork 231
135 lines (120 loc) · 3.99 KB
/
Copy pathpublish.yml
File metadata and controls
135 lines (120 loc) · 3.99 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
133
134
135
name: Publish
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
env:
RELEASE_COMMIT_MSG: 'chore(release): update monorepo packages versions'
jobs:
stable:
name: Stable
if: github.event_name == 'push'
runs-on: ubuntu-latest
concurrency:
group: publish-stable
cancel-in-progress: false
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup environment
uses: ./.github/actions/setup-node
with:
nodeVersion: 24
packageManager: pnpm
packageManagerVersion: '10.17.1'
- name: Build
if: ${{ startsWith(github.event.head_commit.message, env.RELEASE_COMMIT_MSG) }}
run: pnpm --filter=@graphprotocol/graph-cli build
- name: Pack binaries
if: ${{ startsWith(github.event.head_commit.message, env.RELEASE_COMMIT_MSG) }}
run: pnpm --filter=@graphprotocol/graph-cli oclif:pack
- name: Create Release PR or Publish
id: changesets
uses: changesets/action@v1
with:
publish: pnpm release
version: pnpm changeset version
commit: ${{ env.RELEASE_COMMIT_MSG }}
title: Upcoming Release Changes
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_PROVENANCE: 'true'
- name: Attach oclif binaries to GitHub Release
if: steps.changesets.outputs.published == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLISHED: ${{ steps.changesets.outputs.publishedPackages }}
run: |
tag=$(jq -r '.[] | select(.name == "@graphprotocol/graph-cli") | "\(.name)@\(.version)"' <<< "$PUBLISHED")
if [ -n "$tag" ]; then
gh release upload "$tag" packages/cli/dist/*.tar.gz --clobber
fi
snapshot:
name: Snapshot
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
concurrency:
group: publish-snapshot-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup environment
uses: ./.github/actions/setup-node
with:
nodeVersion: 24
packageManager: pnpm
packageManagerVersion: '10.17.1'
- name: Determine snapshot tag
id: tag
run: |
if [ "${{ github.event.pull_request.title }}" = "Upcoming Release Changes" ]; then
echo "tag=rc" >> "$GITHUB_OUTPUT"
# rc snapshots are taken from the Version PR — restore deleted changesets
git checkout HEAD~1 -- .changeset
else
echo "tag=alpha" >> "$GITHUB_OUTPUT"
fi
- name: Check for changesets
id: has_changesets
run: |
if ls .changeset/*.md 2>/dev/null | grep -v README | grep -q .; then
echo "has=true" >> "$GITHUB_OUTPUT"
else
echo "has=false" >> "$GITHUB_OUTPUT"
fi
- name: Build
if: steps.has_changesets.outputs.has == 'true'
run: pnpm build
- name: Snapshot version
if: steps.has_changesets.outputs.has == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm changeset version --snapshot ${{ steps.tag.outputs.tag }}
- name: Publish snapshot
if: steps.has_changesets.outputs.has == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_PROVENANCE: 'true'
run: pnpm changeset publish --tag ${{ steps.tag.outputs.tag }} --no-git-tag