-
Notifications
You must be signed in to change notification settings - Fork 3
164 lines (141 loc) · 6.07 KB
/
Copy pathrelease-motion.yml
File metadata and controls
164 lines (141 loc) · 6.07 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
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
name: Motion - Bump Version and Publish
on:
workflow_dispatch:
inputs:
source_branch:
description: 'Source branch for deploy preview (leave empty for regular release from master)'
required: false
default: ''
type: string
version_strategy:
type: choice
description: Version strategy
options:
- prerelease
- premajor
- preminor
- prepatch
- major
- minor
- patch
dry_run:
description: 'Dry run (preview only)'
required: false
default: false
type: boolean
permissions:
id-token: write # REQUIRED for npm Trusted Publishing
contents: write
pull-requests: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0 # full history for yarn version
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.inputs.source_branch || github.ref }}
- name: Create and checkout release branch
if: ${{ github.event.inputs.dry_run == 'false' }}
id: release_branch
run: |
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
if [ -n "${{ github.event.inputs.source_branch }}" ]; then
BRANCH_NAME="release-dp"
else
BRANCH_NAME="release"
fi
echo "name=$BRANCH_NAME" >> $GITHUB_OUTPUT
git checkout -b "$BRANCH_NAME"
git push -u origin "$BRANCH_NAME"
- name: Setup Node with trusted publishing
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
- name: Set up Yarn
run: |
corepack enable
corepack prepare yarn@4.10.3 --activate
yarn set version 4.10.3
- name: Install dependencies
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: NPQ_PKG_MGR=yarn npx npq install
- name: Build motion package
run: yarn workspace @wix/motion build
- name: Test motion package
run: yarn workspace @wix/motion test
# ---- BUMP VERSION ----
- name: Set deploy preview version
if: ${{ github.event.inputs.dry_run == 'false' && github.event.inputs.source_branch != '' }}
working-directory: packages/motion
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
BASE_VERSION=$(echo "$CURRENT_VERSION" | sed 's/-.*//')
TIMESTAMP=$(date +%Y%m%d%H%M%S)
DP_VERSION="${BASE_VERSION}-dp.${TIMESTAMP}"
yarn version "$DP_VERSION"
- name: Bump version
if: ${{ github.event.inputs.dry_run == 'false' && github.event.inputs.source_branch == '' }}
working-directory: packages/motion
run: yarn version ${{ github.event.inputs.version_strategy }}
- name: Get new version
if: ${{ github.event.inputs.dry_run == 'false' }}
id: get_version
working-directory: packages/motion
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Commit and push version bump
if: ${{ github.event.inputs.dry_run == 'false' }}
run: |
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add .
git commit -m "chore: bump @wix/motion to ${{ steps.get_version.outputs.version }}"
TAG="motion@${{ steps.get_version.outputs.version }}"
git tag -a "$TAG" -m "chore: release @wix/motion ${{ steps.get_version.outputs.version }}"
git push origin ${{ steps.release_branch.outputs.name }}
git push origin "$TAG"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ---- CREATE PULL REQUEST ----
- name: Create Pull Request
if: ${{ github.event.inputs.dry_run == 'false' }}
id: create_pr
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pr } = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `chore: bump @wix/motion to ${{ steps.get_version.outputs.version }}`,
head: '${{ steps.release_branch.outputs.name }}',
base: '${{ github.event.inputs.source_branch || 'master' }}',
body: 'Automated version bump and release PR',
maintainer_can_modify: true
});
return pr.number;
# ---- PUBLISH WITH TRUSTED PUBLISHING ----
- name: npm publish @wix/motion deploy preview (trusted)
if: ${{ github.event.inputs.dry_run == 'false' && github.event.inputs.source_branch != '' }}
run: |
cd packages/motion
npm publish --tag dp --provenance --access=public
- name: npm publish @wix/motion RC (trusted)
if: ${{ github.event.inputs.dry_run == 'false' && github.event.inputs.source_branch == '' && (github.event.inputs.version_strategy == 'prerelease' || github.event.inputs.version_strategy == 'premajor' || github.event.inputs.version_strategy == 'preminor' || github.event.inputs.version_strategy == 'prepatch') }}
run: |
cd packages/motion
npm publish --tag next --provenance --access=public
- name: npm publish @wix/motion Stable (trusted)
if: ${{ github.event.inputs.dry_run == 'false' && github.event.inputs.source_branch == '' && (github.event.inputs.version_strategy == 'major' || github.event.inputs.version_strategy == 'minor' || github.event.inputs.version_strategy == 'patch') }}
run: |
cd packages/motion
npm publish --tag latest --provenance --access=public