Skip to content

Commit 9b4ea67

Browse files
authored
consolidate release actions; remove changeset; remove NPM_TOKEN (#738)
Co-authored-by: cameronvoell <cameronvoell@users.noreply.github.com>
1 parent 426cf6d commit 9b4ea67

5 files changed

Lines changed: 170 additions & 3532 deletions

File tree

.changeset/README.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

.changeset/config.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 115 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
name: Release
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
workflow_dispatch:
5+
inputs:
6+
release_type:
7+
description: 'Release type'
8+
required: true
9+
default: 'dev'
10+
type: choice
11+
options:
12+
- dev
13+
- production
714

815
concurrency: ${{ github.workflow }}-${{ github.ref }}
916

@@ -27,16 +34,115 @@ jobs:
2734
with:
2835
node-version-file: ".nvmrc"
2936
cache: "yarn"
37+
3038
- name: Update npm to latest
3139
run: npm install -g npm@latest
40+
3241
- name: Install dependencies
3342
run: yarn install --frozen-lockfile
34-
- name: Publish
35-
uses: changesets/action@v1
43+
44+
- name: Determine release type
45+
id: release-type
46+
run: |
47+
echo "type=${{ github.event.inputs.release_type }}" >> $GITHUB_OUTPUT
48+
echo "Release type: ${{ github.event.inputs.release_type }}"
49+
50+
- name: Get current version
51+
id: current-version
52+
run: |
53+
CURRENT_VERSION=$(node -p "require('./package.json').version")
54+
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
55+
echo "Current version: $CURRENT_VERSION"
56+
57+
- name: Validate dev version format (dev releases only)
58+
if: steps.release-type.outputs.type == 'dev'
59+
run: |
60+
CURRENT_VERSION="${{ steps.current-version.outputs.current_version }}"
61+
if [[ ! $CURRENT_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+-dev$ ]]; then
62+
echo "Error: For dev releases, package version must be in format MAJOR.MINOR.PATCH-dev"
63+
echo "Current version is $CURRENT_VERSION"
64+
echo "Please update package.json version to follow the dev format (e.g., 1.0.0-dev)"
65+
exit 1
66+
fi
67+
68+
- name: Calculate release version
69+
id: version
70+
run: |
71+
CURRENT_VERSION="${{ steps.current-version.outputs.current_version }}"
72+
RELEASE_TYPE="${{ steps.release-type.outputs.type }}"
73+
74+
if [[ "$RELEASE_TYPE" == "production" ]]; then
75+
# For production, use current version as-is
76+
RELEASE_VERSION="$CURRENT_VERSION"
77+
else
78+
# For dev releases, append commit SHA
79+
SHA=$(git rev-parse --short=7 HEAD)
80+
RELEASE_VERSION="${CURRENT_VERSION}.${SHA}"
81+
fi
82+
83+
echo "release_version=$RELEASE_VERSION" >> $GITHUB_OUTPUT
84+
echo "Release version will be: $RELEASE_VERSION"
85+
86+
- name: Update package.json version
87+
run: |
88+
RELEASE_VERSION="${{ steps.version.outputs.release_version }}"
89+
node -e "
90+
const fs = require('fs');
91+
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
92+
packageJson.version = '$RELEASE_VERSION';
93+
fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, 2) + '\n');
94+
"
95+
echo "Updated package.json version to $RELEASE_VERSION"
96+
97+
- name: Build package
98+
run: yarn build
99+
100+
- name: Create Git tag
101+
run: |
102+
RELEASE_VERSION="${{ steps.version.outputs.release_version }}"
103+
RELEASE_TYPE="${{ steps.release-type.outputs.type }}"
104+
105+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
106+
git config --local user.name "github-actions[bot]"
107+
108+
if [[ "$RELEASE_TYPE" == "production" ]]; then
109+
git tag -a "v$RELEASE_VERSION" -m "Release v$RELEASE_VERSION"
110+
else
111+
git tag -a "v$RELEASE_VERSION" -m "Dev release v$RELEASE_VERSION"
112+
fi
113+
114+
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git "v$RELEASE_VERSION"
115+
116+
- name: Publish to NPM
117+
run: |
118+
RELEASE_TYPE="${{ steps.release-type.outputs.type }}"
119+
120+
if [[ "$RELEASE_TYPE" == "production" ]]; then
121+
echo "Publishing production release..."
122+
npm publish --provenance --access public
123+
else
124+
echo "Publishing development release with prerelease tag..."
125+
npm publish --provenance --access public --tag prerelease
126+
fi
127+
128+
- name: Create GitHub Release
129+
if: steps.release-type.outputs.type == 'production'
130+
uses: actions/create-release@v1
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.RELEASE_GH_TOKEN }}
36133
with:
37-
title: "release: version packages"
38-
commit: "release: version packages"
39-
publish: yarn run release
134+
tag_name: v${{ steps.version.outputs.release_version }}
135+
release_name: Release v${{ steps.version.outputs.release_version }}
136+
draft: false
137+
prerelease: false
138+
139+
- name: Create GitHub Pre-release
140+
if: steps.release-type.outputs.type == 'dev'
141+
uses: actions/create-release@v1
40142
env:
41143
GITHUB_TOKEN: ${{ secrets.RELEASE_GH_TOKEN }}
42-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
144+
with:
145+
tag_name: v${{ steps.version.outputs.release_version }}
146+
release_name: Dev Release v${{ steps.version.outputs.release_version }}
147+
draft: false
148+
prerelease: true

package.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"lint": "expo-module lint",
1111
"test": "expo-module test",
1212
"prepare": "expo-module prepare",
13-
"release": "expo-module build && changeset publish",
1413
"prepublishOnly": "expo-module prepublishOnly",
1514
"pretty": "npx prettier '**/*.{js,ts,tsx}' --write",
1615
"expo-module": "expo-module",
@@ -29,16 +28,6 @@
2928
"bugs": {
3029
"url": "https://github.com/xmtp/xmtp-react-native/issues"
3130
},
32-
"release": {
33-
"branches": [
34-
"main",
35-
{
36-
"name": "beta",
37-
"prerelease": true
38-
},
39-
"+([0-9])?(.{+([0-9]),x}).x"
40-
]
41-
},
4231
"publishConfig": {
4332
"access": "public",
4433
"provenance": true
@@ -47,8 +36,6 @@
4736
"license": "MIT",
4837
"homepage": "https://github.com/xmtp/xmtp-react-native#readme",
4938
"dependencies": {
50-
"@changesets/changelog-git": "^0.2.0",
51-
"@changesets/cli": "^2.27.10",
5239
"@ethersproject/bytes": "^5.7.0",
5340
"@msgpack/msgpack": "^3.0.0-beta2",
5441
"@noble/hashes": "^1.3.3",
@@ -64,7 +51,6 @@
6451
"expo-module-scripts": "^3.0.4",
6552
"expo-modules-core": "^1.5.9",
6653
"prettier": "^3.1.0",
67-
"semantic-release": "^21.0.1",
6854
"typedoc": "^0.25.2",
6955
"viem": "^2.4.0"
7056
},

0 commit comments

Comments
 (0)