-
Notifications
You must be signed in to change notification settings - Fork 18
83 lines (76 loc) · 2.55 KB
/
npm-release-next-version.yml
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
name: Release @next
on:
push:
branches:
- develop
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
packages:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Install Dependencies
run: npm ci
- name: Enter pre next
run: |
[[ ! -f .changeset/pre.json ]] && npx changeset pre enter next || echo 'already in pre mode'
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: npm run publish
version: npm run version
title: "Release"
commit: "chore: version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
plugin-release:
runs-on: ubuntu-latest
needs: [packages]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Publish to the publishing repository
id: push_directory
uses: cpina/github-action-push-to-another-repository@main
env:
API_TOKEN_GITHUB: ${{ secrets.API_GITHUB_TOKEN }}
with:
source-directory: wp/headless-wp/
destination-github-username: '10up'
destination-repository-name: 'headstartwp-plugin'
user-email: [email protected]
commit-message: See ORIGIN_COMMIT from $GITHUB_REF
target-branch: next
- name: Checkout the publishing repository
uses: actions/checkout@v3
with:
repository: 10up/headstartwp-plugin
path: 'repo'
ref: next
token: ${{ secrets.API_GITHUB_TOKEN }}
- name: Create Github Tag
run: echo "VERSION=$(cat repo/package.json | jq -r '.version')" >> $GITHUB_ENV
- name: Tag
run: |
cd repo
git fetch --all --tags
echo "Releasing version $VERSION ..."
if [ $(git tag -l "$VERSION") ]; then
echo "Plugin version already published"
else
git config user.name github-actions
git config user.email [email protected]
git checkout -b "$VERSION"
git tag "$VERSION"
git push --tags
git push --all origin
fi