-
-
Notifications
You must be signed in to change notification settings - Fork 8
139 lines (121 loc) · 4.96 KB
/
release.yml
File metadata and controls
139 lines (121 loc) · 4.96 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
136
137
138
139
name: "A. Release: Docs"
on:
workflow_dispatch:
inputs:
version:
description: 'Choose version bump type (use "current" to release without version bump)'
required: true
type: choice
options:
- current
- patch
- minor
- major
default: patch
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Calculate new version
id: version
env:
VERSION_TYPE: ${{ github.event.inputs.version }}
run: |
CURRENT_VERSION=$(jq -r '.spec' openiap-versions.json)
echo "Current version: $CURRENT_VERSION"
if [ "$VERSION_TYPE" = "current" ]; then
NEW_VERSION="$CURRENT_VERSION"
echo "Using current version (no bump): $NEW_VERSION"
else
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
case "$VERSION_TYPE" in
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
patch) PATCH=$((PATCH + 1)) ;;
esac
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
echo "New version: $NEW_VERSION"
fi
echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.13
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Update version in openiap-versions.json
if: github.event.inputs.version != 'current'
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
jq --arg version "$VERSION" '.spec = $version' openiap-versions.json > openiap-versions.tmp
mv openiap-versions.tmp openiap-versions.json
echo "Updated openiap-versions.json:"
cat openiap-versions.json
- name: Sync version files
if: github.event.inputs.version != 'current'
run: ./scripts/sync-versions.sh
- name: Commit version changes
if: github.event.inputs.version != 'current'
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add openiap-versions.json packages/*/openiap-versions.json
git add packages/gql/package.json packages/docs/package.json packages/google/package.json packages/apple/package.json
git commit -m "chore(docs): bump version to $VERSION"
if ! git pull --rebase origin main; then
echo "⚠️ Rebase conflict detected, auto-resolving version files..."
for conflict_file in $(git diff --name-only --diff-filter=U); do
case "$conflict_file" in
openiap-versions.json|packages/*/openiap-versions.json|packages/gql/package.json|packages/docs/package.json|packages/google/package.json|packages/apple/package.json)
;;
*)
echo "❌ Unexpected conflict in $conflict_file"
exit 1
;;
esac
done
git show HEAD:openiap-versions.json > /tmp/upstream-openiap-versions.json
jq --arg version "$VERSION" '.spec = $version' /tmp/upstream-openiap-versions.json > openiap-versions.json
./scripts/sync-versions.sh
git add openiap-versions.json packages/*/openiap-versions.json
git add packages/gql/package.json packages/docs/package.json packages/google/package.json packages/apple/package.json
GIT_EDITOR=true git rebase --continue || { echo "❌ Rebase continue failed"; exit 1; }
fi
git push origin main
- name: Create Git tag
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
TAG_NAME="docs-$VERSION"
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "Tag $TAG_NAME already exists"
else
git tag -a "$TAG_NAME" -m "Release $TAG_NAME"
git push origin "$TAG_NAME"
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: docs-${{ steps.version.outputs.version }}
name: Docs ${{ steps.version.outputs.version }}
generate_release_notes: true
body: |
## OpenIAP Docs ${{ steps.version.outputs.version }}
### Documentation
- [Documentation](https://openiap.dev)
- [GitHub Repository](https://github.com/hyodotdev/openiap)