Merge branch 'fix-actions' #63
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
paths-ignore: | |
- '**.md' | |
branches: | |
- master | |
tags: | |
- '*' | |
pull_request: | |
paths-ignore: | |
- '**.md' | |
branches: | |
- master | |
- rewrite | |
jobs: | |
build-tarball: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo. | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Setup PHP | |
uses: nanasess/setup-php@v3 | |
with: | |
php-version: 8.1 | |
- name: PHP Lint | |
run: if find . -name "*.php" ! -path "./vendor/*" -print0 | xargs -0 -n 1 -P 8 php -l | grep -v "No syntax errors detected"; then exit 1; fi | |
- name: Setup Env | |
id: setup | |
run: | | |
HASH=$(git rev-parse HEAD | cut -c1-9) | |
echo "::set-output name=commitHash::$HASH" | |
VER=$(grep '$_release' wiki.php |awk '{print $3}' |sed "s/';\|'//g") | |
echo "::set-output name=version::$VER" | |
- name: Build Tarball | |
run: | | |
sudo apt-get install -y gettext | |
git clone https://github.com/wkpark/moniwiki-wikiseed wikiseed | |
echo "Update language files..." | |
(cd locale; sh update-makefile.sh ; make) | |
(cd local/js/locale; sh update-makefile.sh ; make) | |
cat <<EXCLUDE >.excludes | |
.git | |
.git/* | |
.gitmodules | |
.github | |
.github/* | |
applets/FreeMind/Makefile | |
applets/OekakiPlugin/Makefile | |
applets/TWikiDrawPlugin/Makefile | |
imgs/plugin/BBS | |
imgs/plugin/BBS/* | |
plugin/bbs.php | |
theme/paper/.git | |
theme/paper/.git/* | |
theme/plugin/* | |
wikihttpd.php | |
locale/po/*~ | |
.excludes | |
EXCLUDE | |
echo "Build tarball..." | |
tar czvf ../moniwiki-${{ steps.setup.outputs.version }}-${{ steps.setup.outputs.commitHash }}.tgz --owner=root --group=root -X .excludes --transform 's,^\.,moniwiki,' . | |
mkdir release | |
mv ../moniwiki-*.tgz release/ | |
(cd release; tar xvf moniwiki-*.tgz) | |
(cd release; wget https://github.com/wkpark/moniwiki-apserver/releases/download/v0.5/apserver-apache-2.4.54-php-7.4.32.zip) | |
(cd release; zip -r -g apserver-apache-2.4.54-php-7.4.32.zip moniwiki) | |
(rm -rf release/moniwiki) | |
ls -al release | |
- name: Upload Build Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: moniwiki-${{ steps.setup.outputs.version }}-${{ steps.setup.outputs.commitHash }} | |
path: | | |
${{ github.workspace }}/release/moniwiki-*.tgz | |
${{ github.workspace }}/release/apserver-apache-*.zip | |
make-release: | |
name: Create and upload release | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
needs: [build-tarball] | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Get Metadata | |
id: metadata | |
run: | | |
## METADATA SCRIPT | |
echo "::set-output name=version::${GITHUB_REF/refs\/tags\//}" | |
- name: Download build artifacts | |
uses: actions/download-artifact@v3 | |
- name: Generate Checksums | |
run: | | |
## CHECKSUM GENERATION SCRIPT | |
shopt -s extglob | |
echo "### Checksums" > ${{ github.workspace }}/CHECKSUMS.txt | |
for file in ${{ github.workspace }}/**/@(*.pkg|*.exe|*.deb|*.zip|*.tgz); do | |
echo " ${file##*/}: $(sha256sum "${file}" | cut -d " " -f 1)" >> ${{ github.workspace }}/CHECKSUMS.txt | |
done | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 | |
with: | |
draft: false | |
prerelease: ${{ contains(steps.metadata.outputs.version, 'rc') || contains(steps.metadata.outputs.version, 'beta') }} | |
tag_name: ${{ steps.metadata.outputs.version }} | |
name: "moniwiki ${{ steps.metadata.outputs.version }}" | |
body_path: ${{ github.workspace }}/CHECKSUMS.txt | |
files: | | |
${{ github.workspace }}/**/*.zip | |
${{ github.workspace }}/**/*.exe | |
${{ github.workspace }}/**/*.deb | |
${{ github.workspace }}/**/*.tgz | |
${{ github.workspace }}/**/*.pkg |