invoiceninja/.github/workflows/react_release.yml

150 lines
5.4 KiB
YAML

on:
release:
types: [released]
name: React Release
jobs:
build:
name: Upload Release Asset
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: mysql, mysqlnd, sqlite3, bcmath, gd, curl, zip, openssl, mbstring, xml
- name: Checkout code
uses: actions/checkout@v4
with:
ref: v5-develop
fetch-depth: 1
- name: Install composer dependencies
run: |
composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
composer install --no-dev
- name: Set current date to variable
id: set_date
run: echo "current_date=$(date '+%Y-%m-%d')" >> $GITHUB_ENV
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Prepare React FrontEnd
run: |
git clone https://${{secrets.commit_secret}}@github.com/invoiceninja/ui.git
cd ui
git checkout develop
sed -i 's/VITE_IS_TEST=true/VITE_IS_TEST=false/' .env.example
echo VITE_PUSHER_APP_KEY=f0111a02782708da651f >> .env.example
cp .env.example .env
cp ../vite.config.ts.react ./vite.config.js
sed -i '/"version"/c\ "version": " Latest Build - ${{ env.current_date }}",' package.json
npm i
npm run build
cp -r dist/* ../public/
mv ../public/index.html ../resources/views/react/index.blade.php
- name: Prepare JS/CSS assets
run: |
npm i
npm run production
- name: Cleanup Builds
run: |
rm -rf node_modules
rm -rf .git
rm .env || true
rm -rf ui || true
# Set permissions: directories 755, files 644
find . -path ./vendor -prune -o -type f -exec chmod 644 {} \+
find . -path ./vendor -prune -o -type d -exec chmod 755 {} \+
- name: Build project
run: |
shopt -s dotglob
tar --exclude='public/storage' --exclude='invoiceninja.zip' -zcvf /home/runner/work/invoiceninja/invoiceninja.tar *
tar --exclude='public/storage' --exclude='invoiceninja.zip' -zcvf /home/runner/work/invoiceninja/invoiceninja.tar.gz *
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
/home/runner/work/invoiceninja/invoiceninja.tar
/home/runner/work/invoiceninja/invoiceninja.tar.gz
- name: Octane Branch Dockerfiles tag
if: startsWith(github.ref, 'refs/tags/')
run: |
# Extract tag name from ref (e.g., refs/tags/v1.0.0 -> 1.0.0)
TAG_NAME=${GITHUB_REF#refs/tags/}
# Remove leading 'v' from tag name
DOCKER_TAG_NAME="${TAG_NAME#v}-o"
# Create release in dockerfiles repo using GitHub API
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/turbo124/dockerfiles/releases \
-d "{
\"tag_name\": \"$DOCKER_TAG_NAME\",
\"name\": \"$DOCKER_TAG_NAME\",
\"target_commitish\": \"octane\",
\"body\": \"Automated release triggered by main repo release $TAG_NAME\",
\"draft\": false,
\"prerelease\": false
}"
- name: Debian Branch Dockerfiles tag
if: startsWith(github.ref, 'refs/tags/')
run: |
# Extract tag name from ref (e.g., refs/tags/v1.0.0 -> 1.0.0)
TAG_NAME=${GITHUB_REF#refs/tags/}
# Remove leading 'v' from tag name
DOCKER_TAG_NAME="${TAG_NAME#v}-d"
# Create release in dockerfiles repo using GitHub API
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/turbo124/dockerfiles/releases \
-d "{
\"tag_name\": \"$DOCKER_TAG_NAME\",
\"name\": \"$DOCKER_TAG_NAME\",
\"target_commitish\": \"debian\",
\"body\": \"Automated release triggered by main repo release $TAG_NAME\",
\"draft\": false,
\"prerelease\": false
}"
- name: Master Branch Dockerfiles tag
if: startsWith(github.ref, 'refs/tags/')
run: |
# Extract tag name from ref (e.g., refs/tags/v1.0.0 -> 1.0.0)
TAG_NAME=${GITHUB_REF#refs/tags/}
# Remove leading 'v' from tag name
DOCKER_TAG_NAME="${TAG_NAME#v}"
# Create release in dockerfiles repo using GitHub API
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/turbo124/dockerfiles/releases \
-d "{
\"tag_name\": \"$DOCKER_TAG_NAME\",
\"name\": \"$DOCKER_TAG_NAME\",
\"target_commitish\": \"master\",
\"body\": \"Automated release triggered by main repo release $TAG_NAME\",
\"draft\": false,
\"prerelease\": false
}"