-
Notifications
You must be signed in to change notification settings - Fork 2
63 lines (54 loc) · 2.51 KB
/
main.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
# @link https://leoloso.com/posts/github-action-to-release-wp-plugin/
# Creates a zip file containing the installable plugin.
# Steps:
# - Checkout the source code.
# - Run "composer install" to download all dependencies.
# - Use `git archive` to create a zip file.
# - Manually add the `vendor/` directory to that zip file. (Little gross.)
# - Upload the .zip file as an artifact to the action.
# - Upload the .zip file to the release, for download.
name: Generate Installable Plugin, and Upload as Release Asset
# Controls wh en the workflow will run.
on:
# Triggers when a new release is published.
release:
types: [published]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel.
jobs:
build:
name: Upload Release Asset
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job.
steps:
# Checks out the source code.
- name: Checkout code
uses: actions/checkout@v2
# Runs "composer install" and creates the build directory.
- name: Build project
run: |
composer install --no-dev --optimize-autoloader
mkdir build
mkdir ${{ github.event.repository.name }}
mv vendor/ ${{ github.event.repository.name }}/
# Create the zip file. Note that this won't include vendor/, we have to add that next.
- name: Create artifact
run: |
git archive --prefix ${{ github.event.repository.name }}/ -o build/${{ github.event.repository.name }}-${{ github.event.release.name }}.zip HEAD
# Manually add the vendor/ directory into the zip file.
- name: Add vendor files
uses: montudor/action-zip@v0.1.0
with:
args: zip -ur build/${{ github.event.repository.name }}-${{ github.event.release.name }}.zip ${{ github.event.repository.name }}/
# Uploads the zip file to the action.
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: ${{ github.event.repository.name }}-${{ github.event.release.name }}
path: build/${{ github.event.repository.name }}-${{ github.event.release.name }}.zip
# Attaches the zip file to the release.
- name: Upload to release
uses: JasonEtco/upload-to-release@master
with:
args: build/${{ github.event.repository.name }}-${{ github.event.release.name }}.zip application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}