-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
58 lines (53 loc) · 2.19 KB
/
action.yaml
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
name: 'WP Self-Host Updater Generator'
description: 'A GitHub Action for WordPress plugin and theme developers to enable self-hosted updates directly from GitHub. It generates a JSON file from the readme.txt, commits it to the repository, and prepares everything to integrate with custom PHP code for managing updates directly in WordPress. Simplify self-hosting with this automated tool.'
author: 'Eduardo Villão <dev@eduardovillao.me>'
inputs:
github-token:
description: 'GitHub Token with write permissions'
required: true
runs:
using: 'composite'
steps:
- name: Define vars
run: |
echo "USERNAME=${{ github.repository_owner }}" >> $GITHUB_ENV
echo "REPO=${{ github.event.repository.name }}" >> $GITHUB_ENV
echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV
echo "FILENAME=${{ github.event.repository.name }}-${{ github.ref_name }}.zip" >> $GITHUB_ENV
shell: bash
- name: Generate JSON
run: |
node ${{ github.action_path }}/src/create-json.js
shell: bash
- name: Commit JSON to Main
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
git add .
git commit -m "Update JSON for version $TAG"
git push
shell: bash
- name: Generate release ZIP
run: |
git archive --format=zip --prefix=${{ env.REPO }}/ --output=${{ env.FILENAME }} HEAD
shell: bash
- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ env.TAG }}
release_name: "Release ${{ env.TAG }}"
body: "Release of the version ${{ env.TAG }} generated by WP Self-Host Updater Generator."
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.FILENAME }}
asset_name: ${{ env.FILENAME }}
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ inputs.github-token }}