-
Notifications
You must be signed in to change notification settings - Fork 146
159 lines (131 loc) · 4.56 KB
/
deploy-create-release.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
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
name: 'Deploy / Create Release'
on:
milestone:
types: [ closed ]
env:
ARTIFACT_NAME: 'coblocks-plugin'
ARTIFACT_ZIP: 'coblocks.zip'
jobs:
update:
name: Update version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Setup git user
uses: godaddy-wordpress/setup-godaddy-git-user@v1
- name: Setup WP-CLI
uses: godaddy-wordpress/setup-wp-cli@1
# Yarn is still required on this project, so we need to make sure it is
# installed globally.
- name: Install yarn
run: npm i -g yarn
- name: Set version
run: |
echo "NEW_TAG_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV
- name: Validate tag version
run: |
MATCH='^([0-9]+\.){2}(\*|[0-9]+)(-.*)?$'
if ! [[ $NEW_TAG_VERSION =~ $MATCH ]]; then
echo "::error::Milestone title does not match semver format: '$NEW_TAG_VERSION'"
exit 1
fi
- name: Update changelog.txt
run: |
echo -e "${{ github.event.milestone.title }} / $(date +%Y-%m-%d)\n===================\n${{ github.event.milestone.description }}\n\n$(cat changelog.txt)" > changelog.txt
- name: Install dependencies
run: |
composer install --no-interaction --no-progress --no-suggest --optimize-autoloader --prefer-dist
yarn install --immutable
- name: Run version update
run: npm --no-git-tag-version version $NEW_TAG_VERSION
- name: Push changes
run: |
git add -A .
git commit -m "Updating to version $NEW_TAG_VERSION" --no-verify
git push
build:
name: Create artifact
uses: ./.github/workflows/deploy-create-artifact.yml
needs: update
tag:
runs-on: ubuntu-latest
name: Tag new version
needs: update
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- name: Setup git user
uses: godaddy-wordpress/setup-godaddy-git-user@v1
- name: Set version
run: |
echo "NEW_TAG_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV
- name: Publish new tag
run: |
git tag $NEW_TAG_VERSION
git push origin $NEW_TAG_VERSION
release:
runs-on: ubuntu-latest
name: Create new release
needs: [ build, tag ]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- name: Set release version
run: |
echo "RELEASE_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create $RELEASE_VERSION -n "${{ github.event.milestone.description }}" -t "$RELEASE_VERSION"
- name: Download plugin
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
- name: Upload asset to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload $RELEASE_VERSION ${{ env.ARTIFACT_ZIP }}
# deploy:
# name: Deploy to WordPress.org
# needs: [ build, tag ]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# ref: ${{ github.event.repository.default_branch }}
# - name: Set version
# run: |
# echo "NEW_TAG_VERSION=${{ github.event.milestone.title }}" >> $GITHUB_ENV
# - name: Download plugin
# uses: actions/download-artifact@v3
# with:
# name: ${{ env.ARTIFACT_NAME }}
# path: .artifacts
# - name: Unzip artifact
# run: |
# mkdir -p .wp-plugin-deploy
# unzip .artifacts/${{ env.ARTIFACT_ZIP }} -d .wp-plugin-deploy/
# mv .wp-plugin-deploy/coblocks .wp-plugin-deploy/coblocks-artifact
# - name: Deploy to WordPress.org
# uses: godaddy-wordpress/deploy-plugin-artifact@v1
# with:
# plugin-name: coblocks
# plugin-version: ${{ env.NEW_TAG_VERSION }}
# plugin-assets: ".wordpress-org"
# svn-username: "${{ secrets.GODADDY_WPORG_USERNAME }}"
# svn-password: "${{ secrets.GODADDY_WPORG_PASSWORD }}"