This repository has been archived by the owner on Mar 31, 2022. It is now read-only.
generated from luehrsenheinrich/wp-plugin-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (114 loc) Β· 4.79 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
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
# This workflow creates a release based upon the information in our wp-boilerplate repositories.
# It assumes that `npm install`, `composer install` and `npx grunt release` are valid commands.
# The action expects a valid zip file in the `./update/` folder and the `slug` key in the
# `package.json` to be set.
name: π Create Release
on:
# This action is triggered manually.
workflow_dispatch:
inputs:
version:
description: 'The version number of this release. Runs `npm version`.'
required: true
default: 'patch'
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: π Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.GH_ADMIN_TOKEN }}
- name: βοΈ Configure git
run: |
git config user.name $GITHUB_ACTOR
git config user.email gh-actions-${GITHUB_ACTOR}@github.com
- uses: actions/setup-node@v1
with:
node-version: 12
- name: βοΈ Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer:v2
- name: βοΈ Get project slug
id: package
run: echo "::set-output name=slug::$(node -p "require('./package.json').slug")"
- name: πΎ Get node.js cache directory
id: node-cache-dir
run: echo "::set-output name=dir::$(npm config get cache)" # Use $(yarn cache dir) for yarn
- name: πΎ Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.node-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} # Use '**/yarn.lock' for yarn
restore-keys: ${{ runner.os }}-node-
- name: πΎ Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: βοΈ Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: βοΈ Install Composer Packages
run: composer install --prefer-dist
- name: βοΈ Install Node Packages
run: npm install
- name: βοΈ Create Changelog
shell: bash
id: changelog
run: |
log=$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:'* %s (%h)')
log="${log//'%'/'%25'}"
log="${log//$'\n'/'%0A'}"
log="${log//$'\r'/'%0D'}"
echo "::set-output name=log::$log"
- name: Check Status
run: git status
- name: πΌ Bump version
id: version
run: echo "::set-output name=version::$(npm version ${{ github.event.inputs.version }} -m 'Tagging %s' -f)"
- name: π Build Release
run: npx grunt release
- name: Push the version to git
run: |
git push && git push --tags
env:
GITHUB_TOKEN: ${{ secrets.GH_ADMIN_TOKEN }}
- name: π Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.version.outputs.version }}
release_name: Release ${{ steps.version.outputs.version }}
body: |
${{ steps.changelog.outputs.log }}
draft: false
prerelease: false
- name: π¦ Add asset to release
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./update/${{ steps.package.outputs.slug }}.zip
asset_name: ${{ steps.package.outputs.slug }}-${{ steps.version.outputs.version }}.zip
asset_content_type: application/zip
- name: π’ Deploy to Update Server
if: ${{ success() }}
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.UPDATE_SERVER_HOST }}
username: ${{ secrets.UPDATE_SERVER_USER }}
password: ${{ secrets.UPDATE_SERVER_PASSWORD }}
local-dir: ./update/
state-name: .${{ steps.package.outputs.slug }}-sync-state.json