Skip to content

Commit

Permalink
Automated PHAR build using GitHub Actions (#3)
Browse files Browse the repository at this point in the history
* Create build_phar.yml

* Fix ConsoleScript URL

* FIxing releases tag

* Attempt #2

* Change tag and SHA to short version

* Delete unused files

* oops

* Oops again

* Oops again

* Add RFC 3339 date

* Hopefully this is the last

* This time

* ...
  • Loading branch information
KygekDev authored Mar 17, 2022
1 parent d916e78 commit cd00a5b
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build_phar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build PHAR

on: [ push, pull_request ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout GitHub repo
uses: actions/checkout@v2

# https://stackoverflow.com/a/59819441
- name: Set custom variables
id: vars
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
echo "::set-output name=date::$(date --rfc-3339=seconds)"
- name: Make '.build' directory
run: mkdir .build

- name: Download DevTools/ConsoleScript.php
run: wget -O .build/build.php https://raw.githubusercontent.com/pmmp/DevTools/master/src/ConsoleScript.php

- name: Delete unused files
run: |
shopt -s extglob
rm -rfv !("src"|"plugin.yml"|".build"|".git")
- name: Display structure of current working directory
run: ls -laR

- name: Build source to PHAR
run: php -dphar.readonly=0 .build/build.php --make ./ --out .build/Height_${{ steps.vars.outputs.sha_short }}.phar

- name: Release PHAR artifact to GitHub Releases
uses: softprops/action-gh-release@v1
with:
tag_name: build_${{ steps.vars.outputs.sha_short }}
name: Height - Build ${{ steps.vars.outputs.sha_short }}
body: |
Build Date: `${{ steps.vars.outputs.date }}`
Build SHA: ${{ steps.vars.outputs.sha_short }}
Last Commit Message: `${{ github.event.commits[0].message }}`
## IMPORTANT
This is an unstable build of the Height plugin. Only use this build for testing or development purposes.
### Why we use GitHub Releases?
We use GitHub Releases instead of GitHub Actions artifacts to retain every build as long as possible.
prerelease: true
fail_on_unmatched_files: true
files: |
.build/Height_${{ steps.vars.outputs.sha_short }}.phar

0 comments on commit cd00a5b

Please sign in to comment.