Skip to content

Commit

Permalink
Adds the Build & Release GH workflow. Updates .editorconfig.
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohillebrandt committed Feb 22, 2023
1 parent a32c0f1 commit f1fb86b
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ trim_trailing_whitespace = true
[*.{md,yml,xml}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = false
trim_trailing_whitespace = true
64 changes: 64 additions & 0 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build & Release

on:
workflow_dispatch:
inputs:
tag:
description: 'Version tag (e.g. 1.4.0)'
required: true

jobs:
build_and_release:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Confirm the version tag format is valid
run: if echo "${{ github.event.inputs.tag }}" | egrep -qv "([0-9]{1,}.){2}[0-9]{1,}"; then echo "Version tag format is invalid."; exit 1; fi

- name: Extract changes from the CHANGELOG.md file
run: |
grep "\[${{ github.event.inputs.tag }}\]" CHANGELOG.md -A1000 | tail -n +2 | sed '/## \[.*/Q' | sed '$d' > /tmp/changelog_output
if [[ -s "/tmp/changelog_output" ]]; then cat /tmp/changelog_output; else echo "Please make sure the CHANGELOG.md is updated: couldn't find the changes for '${{ github.event.inputs.tag }}'."; exit 1; fi
- name: Search for the version tag and replace it
run: grep -Rin "@since {VERSION}" --exclude-dir=vendor --exclude-dir=assets --exclude-dir=.github --exclude-dir=.git | while read -r file; do filename=$(echo "$file" | cut -d ':' -f1); if echo "$filename" | egrep -qv ".(js|php)$"; then continue; fi; sed -i "s/@since {VERSION}$/@since ${{ github.event.inputs.tag }}/g" $filename; done

- name: Update constants
run: |
if [[ -f "supervisor.php" ]]; then sed -i '/Version: */d' supervisor.php; sed -i "/Description:*/a \ * Version: ${{ github.event.inputs.tag }}" supervisor.php; sed -i "s/'SUPV_VERSION', '.*'/'SUPV_VERSION', '${{ github.event.inputs.tag }}'/g" supervisor.php; fi
- name: Commit changes
run: |
git config --global user.name "$(git log -n 1 --pretty=format:%an)"
git config --global user.email "$(git log -n 1 --pretty=format:%ae)"
git commit -a -m "Updates the version tag to ${{ github.event.inputs.tag }}."
git tag ${{ github.event.inputs.tag }}
- name: Push changes & Create the tag
uses: ad-m/github-push-action@master
with:
branch: ${{ github.head_ref }}
tags: true

- name: Build zip
run: |
mkdir /tmp/supervisor
cp -R * /tmp/supervisor
cd /tmp/supervisor
rm -rf assets/scss .git* .editorconfig *.md phpcs.xml.dist composer.* package*.json Gruntfile.js
zip -r supervisor-${{ github.event.inputs.tag }}.zip .
ls -lah
cd -
- name: Create the GitHub release
uses: softprops/action-gh-release@v1
with:
body_path: /tmp/changelog_output
files: /tmp/supervisor/supervisor-${{ github.event.inputs.tag }}.zip
prerelease: false
tag_name: "${{ github.event.inputs.tag }}"

0 comments on commit f1fb86b

Please sign in to comment.