Skip to content

Commit

Permalink
change action
Browse files Browse the repository at this point in the history
brokiem committed Aug 12, 2022
1 parent 98ffae5 commit f39bede
Showing 3 changed files with 105 additions and 39 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/action.yml

This file was deleted.

103 changes: 103 additions & 0 deletions .github/workflows/phar-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: CI

on: [ push ]

jobs:
build:
name: Build plugin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Prepare directories
run: |
mkdir target
mkdir plugin
- name: Move files to plugin folder
run: |
mv src plugin.yml -t plugin
- name: Setup PHP 8.1
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
ini-values: phar.readonly=0

- name: Read plugin name
id: plugin-name
uses: KJ002/read-yaml@main
with:
file: './plugin/plugin.yml'
key-path: '["name"]'

- name: Download ConsoleScript
run: wget https://gist.githubusercontent.com/brokiem/3a407df6372ed1410cfb38cf99762a3f/raw/3f7e65b169a13bff5f2ec91669f9b474cf25a6cc/ConsoleScript.php

- name: Build plugin
run: php ConsoleScript.php --make / --relative plugin --out target/${{ steps.plugin-name.outputs.data }}.phar

- name: Check libraries file
id: libraries-file
uses: andstor/file-existence-action@v1
with:
files: ".libraries.yml"

- name: Read libraries
if: steps.libraries-file.outputs.files_exists == 'true'
id: libraries
uses: KJ002/read-yaml@main
with:
file: './.libraries.yml'
key-path: '["libs"]'

- name: Download virions
if: steps.libraries-file.outputs.files_exists == 'true'
run: php -r 'foreach(${{ steps.libraries.outputs.data }} as $lib){ exec("wget $lib"); echo "Downloaded virion " . basename($lib); }'

- name: Inject virions
if: steps.libraries-file.outputs.files_exists == 'true'
run: php -r 'foreach(${{ steps.libraries.outputs.data }} as $lib){ exec("php " . basename($lib) . " target/${{ steps.plugin-name.outputs.data }}.phar"); echo "\nInjected virion " . basename($lib); }'

- name: Compress phar
run: php -r '(new \Phar("./target/${{ steps.plugin-name.outputs.data }}.phar"))->compressFiles(\Phar::GZ); echo "\nFinished compression";'

- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: ${{ steps.plugin-name.outputs.data }}.phar
path: target/${{ steps.plugin-name.outputs.data }}.phar

prepare-release:
name: Make release
needs: [ build ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Download artifact
uses: actions/download-artifact@v2

- name: Read plugin name
id: plugin-name
uses: KJ002/read-yaml@main
with:
file: './plugin.yml'
key-path: '["name"]'

- name: Read plugin version
id: plugin-version
uses: KJ002/read-yaml@main
with:
file: './plugin.yml'
key-path: '["version"]'

- name: Create and publish release
uses: marvinpinto/action-automatic-releases@v1.2.1
with:
automatic_release_tag: "${{ steps.plugin-version.outputs.data }}"
repo_token: "${{ secrets.GITHUB_TOKEN }}"
title: "${{ steps.plugin-name.outputs.data }} v${{ steps.plugin-version.outputs.data }}"
files: |
${{ steps.plugin-name.outputs.data }}.phar
prerelease: false
2 changes: 2 additions & 0 deletions .libraries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
libs:
- https://poggit.pmmp.io/r/189705/Sobana_dev-1.phar

0 comments on commit f39bede

Please sign in to comment.