-
Notifications
You must be signed in to change notification settings - Fork 54
169 lines (147 loc) · 5.42 KB
/
release.yaml
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Publish packages and create tags
on:
workflow_dispatch:
inputs:
release_type:
description: "Type of release (prerelease, prepatch, patch, minor, preminor, major)"
required: true
default: "patch"
dry_run:
description: "Dry run (no actual publishing or commits)"
required: false
default: false
type: boolean
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: pnpm/action-setup@v3
with:
version: 10.0.0
- name: Setup Node.js with PNPM cache
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'pnpm'
# The cache will be invalidated if these files change
cache-dependency-path: '**/pnpm-lock.yaml'
# Cache the PNPM store to speed up installations
- name: Get PNPM store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup PNPM cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# Optional: Cache build output for even faster subsequent builds
- name: Cache build output
uses: actions/cache@v3
with:
path: |
**/dist
**/.turbo
key: ${{ runner.os }}-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-
# Add Cargo cache for torii-wasm
- name: Cache Cargo dependencies and build artifacts
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
packages/torii-wasm/dojo.c/target
key: ${{ runner.os }}-cargo-${{ hashFiles('packages/torii-wasm/**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- run: curl -L https://install.dojoengine.org | bash
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.9.2"
- run: /home/runner/.config/.dojo/bin/dojoup -v v1.2.1
- run: |
cd worlds/dojo-starter
/home/runner/.config/.dojo/bin/sozo build
- run: |
cd worlds/onchain-dash
/home/runner/.config/.dojo/bin/sozo build
- name: Configure Git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: "Setup npm for npmjs"
run: |
npm config set registry https://registry.npmjs.org/
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Install Protobuf Compiler
run: sudo apt-get install -y protobuf-compiler
- name: Install dependencies
run: pnpm install
- name: Check for packages to be bumped
id: check-status
run: |
# Run changeset status and capture output
STATUS=$(pnpm changeset status)
echo "Changeset status:"
echo "$STATUS"
# Check if we have packages to bump
if echo "$STATUS" | grep -q "NO packages to be bumped at patch" && \
echo "$STATUS" | grep -q "NO packages to be bumped at minor" && \
echo "$STATUS" | grep -q "NO packages to be bumped at major"; then
echo "No packages need to be bumped at any level. Exiting workflow."
echo "has_changes=false" >> $GITHUB_OUTPUT
exit 0
else
echo "Found packages that need to be bumped. Continuing workflow."
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Version packages
id: changesets-version
run: |
# Apply version bump based on release type
pnpm changeset version
# If this is a dry run, revert the version changes
if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then
echo "DRY RUN: Would version packages to ${NEW_VERSION}"
git checkout -- .
fi
- name: Commit changes
if: ${{ github.event.inputs.dry_run != 'true' }}
run: |
if git diff --quiet && git diff --staged --quiet; then
echo "No changes to commit"
else
git add .
git commit -m "chore: release"
git push origin refs/heads/main:refs/heads/main
fi
- name: Publish to npm
if: ${{ github.event.inputs.dry_run != 'true' }}
run: pnpm release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Dry run - Show npm publish
if: ${{ github.event.inputs.dry_run == 'true' }}
run: |
echo "DRY RUN: Would publish the following packages to npm:"
pnpm release:dry-run
- name: Create and push tag
if: ${{ github.event.inputs.dry_run != 'true' }}
run: |
pnpm changeset tag
git push --tags
- name: Dry run - Show git changes
if: ${{ github.event.inputs.dry_run == 'true' }}
run: |
TAGS=$(pnpm changeset tag)
echo "DRY RUN: Would commit changes with message: chore: release"
echo "DRY RUN: Would create and push tag: $TAGS"
git status