-
Notifications
You must be signed in to change notification settings - Fork 2
77 lines (68 loc) · 2.59 KB
/
prerelease.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
# Job that makes prereleases on the alpha and beta branches.
# Excluded files and folders that should not be part of the plugin is defined in .distignore
# Plugin can be downloaded from the release page on GitHub
name: Prerelease
on:
push:
branches:
# - beta
# - alpha
jobs:
calculate-next-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
# Running semantic-release in dry-run mode to calculate the next version, without publishing anything
- run: npx semantic-release --dry-run
id: calculate-next-version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
new-release-published: ${{ steps.calculate-next-version.outputs.new-release-published }}
new-release-version: ${{ steps.calculate-next-version.outputs.new-release-version }}
prerelease:
runs-on: ubuntu-latest
needs: calculate-next-version
if: needs.calculate-next-version.outputs.new-release-published == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Dependencies
run: npm ci
- name: Semantic Release - create prerelease
id: semantic
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Creates the plugin zip and excludes the files from .distignore, then uploads it as an artifact (unzipped since github zips it automatically)
- name: Build plugin zip
id: build_zip
uses: 10up/action-wordpress-plugin-build-zip@stable
# We need to download the plugin artifact to be able to use it in the next steps
- name: Download the plugin artifact
uses: actions/download-artifact@v3
with:
name: ${{ github.event.repository.name }}
path: ${{ github.workspace }}/zipfile
# Re-zip the plugin artifact to be able to upload it as a release asset
- name: Re-zip the plugin artifact
run: |
cd zipfile
zip -r ../${{ github.event.repository.name }}.zip .
# Upload the plugin zip as a release asset
- name: Update GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.calculate-next-version.outputs.new-release-version }}
files: ./${{ github.event.repository.name }}.zip
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}