-
Notifications
You must be signed in to change notification settings - Fork 64
114 lines (93 loc) · 2.89 KB
/
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
name: Create Release
on:
milestone:
types: [ closed ]
env:
ARTIFACT_NAME: 'go-theme'
ARTIFACT_ZIP: 'go.zip'
jobs:
update:
name: Update version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Setup git user
uses: godaddy-wordpress/setup-godaddy-git-user@v1
# 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: Install dependencies
run: |
yarn install --immutable
- name: Run version update
run: yarn version --new-version $NEW_TAG_VERSION
- name: Push changes
run: |
git add .
git commit -m "Updating to version $NEW_TAG_VERSION" --no-verify
git push
build:
name: Build theme
uses: ./.github/workflows/create-artifact.yml
needs: update
tag:
runs-on: ubuntu-latest
name: Tag new version
needs: update
steps:
- name: Checkout
uses: actions/checkout@v3
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@v3
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 theme
uses: actions/download-artifact@v3
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 }}