Skip to content

Commit

Permalink
使用ayanamist改进的编译工作流及其适配JBR17的patch
Browse files Browse the repository at this point in the history
  • Loading branch information
RikudouPatrickstar committed Aug 28, 2022
1 parent c13f862 commit b527989
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 217 deletions.
186 changes: 86 additions & 100 deletions .github/workflows/jbr-linux-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,127 +2,113 @@ name: jbr-linux-x64

on:
workflow_dispatch:
push:
branches:
- master
schedule:
- cron: 0 0 1 * *
inputs:
release_id:
required: true
default: 'latest'
type: string
description: "Release id or tag"
jbr_branch:
required: false
type: string
description: "JBR branch"

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- name: Clone Repository
uses: actions/checkout@v1
uses: actions/checkout@v3

- name: Generate Variables
id: vars
run: |
release_id='${{ github.event.inputs.release_id }}'
curl -H "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -sfL -m 60 -o /tmp/latest.json "${{ github.api_url }}/repos/JetBrains/JetBrainsRuntime/releases/${release_id:-latest}"
release_name=$(jq -r .name /tmp/latest.json)
echo "Release: $release_name"
echo ::set-output name=release_name::"$release_name"
html_url=$(jq -r .html_url /tmp/latest.json)
echo "Release URL: $html_url"
echo ::set-output name=release_body::"$html_url"
tag_name=$(jq -r .tag_name /tmp/latest.json)
echo "Tag: $tag_name"
echo ::set-output name=tag_name::"$tag_name"
if [[ "$tag_name" == jbr17* ]]; then
JBSDK_VERSION=$(sed -E 's/^jbr([0-9_.]+)b.*$/\1/' <<< "$tag_name")
build_number=$(sed -E 's/^jbr[0-9_.]+b([0-9.]+)$/\1/' <<< "$tag_name")
elif [[ "$tag_name" == jbr-release-17.* ]]; then
JBSDK_VERSION=$(sed -E 's/^jbr-release-([0-9_.]+)b.*$/\1/' <<< "$tag_name")
build_number=$(sed -E 's/^jbr-release-[0-9_.]+b([0-9.]+)$/\1/' <<< "$tag_name")
else
echo unknown tag name: $tag_name
exit 1
fi
echo "JBSDK Version: $JBSDK_VERSION"
echo ::set-output name=JBSDK_VERSION::"$JBSDK_VERSION"
echo "Build Number: $build_number"
echo ::set-output name=build_number::"$build_number"
ref='${{ github.event.inputs.jbr_branch }}'
if [[ -z "$ref" ]]; then
ref="jb${JBSDK_VERSION}-b${build_number}"
fi
echo "Ref: $ref"
echo ::set-output name=ref::"$ref"
- name: Init Build Dependencies
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get remove -y --purge azure-cli ghc zulu* hhvm llvm* firefox google* dotnet* powershell openjdk* mysql* php*
sudo -E rm -rf /usr/share/dotnet /etc/mysql /etc/php /usr/lib/jvm/
sudo -E apt-get update -y
sudo -E apt-get install -y ant autoconf bison build-essential cmake flex git gperf ksh \
libasound2-dev libavcodec-dev libavformat-dev libcups2-dev libfontconfig1-dev \
libgl1-mesa-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
libgtk2.0-dev libgtk-3-dev libjpeg-dev libpng-dev libudev-dev libx11-dev libxext-dev \
libxml2-dev libxrandr-dev libxrender-dev libxslt1-dev libxt-dev libxtst-dev libxxf86vm-dev \
make mercurial openjdk-11-jdk pkg-config ruby tree x11proto-core-dev x11proto-xf86vidmode-dev zip
sudo -E apt-get autoremove -y --purge
sudo -E apt-get clean -y
- name: Generate Information
id: gen_info
env:
TZ: Asia/Shanghai
run: |
release_tag="$(date +%Y-%m-%d_%H-%M)"
release_name="jbr-linux-x64-$release_tag"
release_description="${{ secrets.DESC }}"
echo "##[set-output name=release_tag;]$release_tag"
echo "##[set-output name=release_name;]$release_name"
echo "##[set-output name=release_description;]$release_description"
- name: Compile JCEF
env:
JDK_11: /usr/lib/jvm/java-11-openjdk-amd64
ANT_HOME: /usr/share/ant
run: |
git clone https://github.com/JetBrains/jcef.git jcef
cd jcef
# reset to commit 4ef9139
git reset --hard 4ef9139
cd jb/tools/linux && chmod +x *
./build.sh all
- name: List Paths
sudo apt-get update -y
sudo apt-get install -y libasound2-dev libavcodec-dev libavformat-dev libcups2-dev libgl1-mesa-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgtk2.0-dev libgtk-3-dev libudev-dev libxrandr-dev libxslt1-dev libxtst-dev libxxf86vm-dev x11proto-xf86vidmode-dev
sudo apt-get clean -y
- name: Prepare JCEF
run: |
cd jcef
ls -a
echo
tree -a
aria2c -o jbrsdk_jcef.tgz 'https://cache-redirector.jetbrains.com/intellij-jbr/jbrsdk_jcef-${{ steps.vars.outputs.JBSDK_VERSION }}-linux-x64-b${{ steps.vars.outputs.build_number }}.tar.gz'
mkdir jcef_linux_x64
tar -zxvf jbrsdk_jcef.tgz --strip-components=1 -C jcef_linux_x64 --wildcards -- 'jbrsdk_jcef-*/jmods/gluegen.rt.jmod' 'jbrsdk_jcef-*/jmods/jogl.all.jmod' 'jbrsdk_jcef-*/jmods/jcef.jmod'
rm -f jbrsdk_jcef.tgz
- name: Clone JBR Repository
uses: actions/checkout@v3
with:
repository: JetBrains/JetBrainsRuntime
ref: ${{ steps.vars.outputs.ref }}
fetch-depth: 0 # 这里必须拉取全部历史,下面的mkimages_x64.sh里面会通过git log找tag
path: JetBrainsRuntime

- name: Patch & Compile JetBrainsRuntime with JCEF
env:
JAVA_HOME: /usr/lib/jvm/java-11-openjdk-amd64
JDK_HOME: /usr/lib/jvm/java-11-openjdk-amd64
id: compile
run: |
git config --global core.autocrlf input
git clone -b master --single-branch https://github.com/JetBrains/JetBrainsRuntime.git
cd JetBrainsRuntime
mkdir jcef_linux_x64 && tar zxf ../jcef/jcef_linux_x64.tar.gz -C jcef_linux_x64
git apply -p0 < jb/project/tools/patches/add_jcef_module.patch
mv ../idea.patch ./
patch -p1 < idea.patch
sh ./configure --disable-warnings-as-errors --with-import-modules=./jcef_linux_x64/modular-sdk
make images
- name: List Paths
run: |
cd JetBrainsRuntime
ls -a
echo
tree -a
git log -1
- name: Reduce Size
env:
BASE_DIR: build/linux-x86_64-normal-server-release/images
JBR_BUNDLE: jbr_jcef
JCEF_PATH: ../jcef/jcef_build/native/Release
run: |
cd JetBrainsRuntime
cat jb/project/tools/common/modules.list > modules_tmp.list
rm -rf ${BASE_DIR}/${JBR_BUNDLE}
${BASE_DIR}/jdk/bin/jlink \
--module-path ${BASE_DIR}/jdk/jmods --no-man-pages --compress=2 \
--add-modules $(xargs < modules_tmp.list | sed s/" "//g) --output $BASE_DIR/$JBR_BUNDLE
cp -R $BASE_DIR/$JBR_BUNDLE $BASE_DIR/jbr
rsync -av ${JCEF_PATH}/ $BASE_DIR/$JBR_BUNDLE/lib --exclude="modular-sdk"
grep -v "^JAVA_VERSION" ${BASE_DIR}/jdk/release | grep -v "^MODULES" >> $BASE_DIR/$JBR_BUNDLE/release
rm -rf ${BASE_DIR}/jbr
cp -R ${BASE_DIR}/${JBR_BUNDLE} ${BASE_DIR}/jbr
- name: Package Artifact
run: |
cd JetBrainsRuntime/build/linux-x86_64-normal-server-release/images
zip -r jbr-linux-x64.zip ./jbr/*
mv jbr-linux-x64.zip ../../../../
patch -p1 < ../idea.patch
- name: Upload Artifact
uses: actions/upload-artifact@master
with:
name: ${{ steps.gen_info.outputs.release_tag }}
path: jbr-linux-x64.zip
mv ../jcef_linux_x64 ./
export BOOT_JDK="$JAVA_HOME_17_X64"
jb/project/tools/linux/scripts/mkimages_x64.sh '${{ steps.vars.outputs.build_number }}' jcef
echo ::set-output name=jbr_image::"$(ls -1 jbr_jcef-*-linux-x64-*.tar.gz)"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.gen_info.outputs.release_tag }}
release_name: ${{ steps.gen_info.outputs.release_name }}
body: ${{ steps.gen_info.outputs.release_description }}
tag_name: ${{ steps.vars.outputs.tag_name }}
release_name: ${{ steps.vars.outputs.release_name }}
body: ${{ steps.vars.outputs.release_body }}
draft: false
prerelease: true

Expand All @@ -133,7 +119,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./jbr-linux-x64.zip
asset_name: ${{ steps.gen_info.outputs.release_name }}.zip
asset_content_type: application/zip
asset_path: JetBrainsRuntime/${{ steps.compile.outputs.jbr_image }}
asset_name: ${{ steps.compile.outputs.jbr_image }}
asset_content_type: application/gzip

Loading

0 comments on commit b527989

Please sign in to comment.