-
Notifications
You must be signed in to change notification settings - Fork 2
83 lines (72 loc) · 2.87 KB
/
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
# Job that makes releases on the main branch.
# Excluded files and folders that should not be part of the plugin is defined in .distignore
name: Release to WordPress plugin repository
on:
push:
branches:
# - main pause for now
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 }}
release:
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 release
id: semantic
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Creates the plugin and excludes the files from .distignore, then deploys it to the WordPress SVN
- name: Deploy Plugin to WordPress SVN
uses: 10up/action-wordpress-plugin-deploy@stable
env:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SLUG: ledyer-checkout-for-woocommerce
# 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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}