From c30360828db9db1b947998c4bc46d00d4c890847 Mon Sep 17 00:00:00 2001 From: FriwiDev Date: Mon, 15 Nov 2021 21:50:29 +0100 Subject: [PATCH] Begin release process --- .github/workflows/build.yml | 48 ++++++++++++++++++++-- .gitignore | 4 +- DockerfileLinux | 3 +- compile_linux.sh | 11 ++--- scripts/run_linux.sh | 2 +- tools/create_release_info.sh | 80 ++++++++++++++++++++++++++++++++++++ 6 files changed, 137 insertions(+), 11 deletions(-) create mode 100755 tools/create_release_info.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1be582a..272912e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,14 +3,55 @@ name: build on: workflow_dispatch: inputs: + repo: + description: 'Git repository to clone' + required: true + default: 'https://bitbucket.org/chromiumembedded/java-cef.git' ref: description: 'Git commit id to checkout' - required: false + required: true default: 'master' jobs: + create-release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Generate release info + run: | + chmod +x tools/create_release_info.sh + ./create_release_info.sh ${{ github.event.inputs.repo }} ${{ github.event.inputs.ref }} https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} ${{github.run_number}} + - name: Create Release + id: create_release + uses: softprops/action-gh-release@v1 + with: + name: ${{env.release_name}} + tag_name: ${{env.release_tag_name}} + body_path: tools/release_message.md + - name: Add LICENSE + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + asset_path: tools/LICENSE.txt + asset_name: LICENSE + asset_content_type: text/plain + - name: Add build_meta.json + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + asset_path: tools/build_meta.json + asset_name: build_meta.json + asset_content_type: application/json + + linux-amd64: runs-on: ubuntu-latest + needs: create-release steps: - uses: actions/checkout@v1 - name: Set up QEMU @@ -24,7 +65,7 @@ jobs: name: Build run: | chmod +x compile_linux.sh - ./compile_linux.sh amd64 Release ${{ github.event.inputs.ref }} + ./compile_linux.sh amd64 Release ${{ github.event.inputs.repo }} ${{ github.event.inputs.ref }} - name: Export artifacts uses: actions/upload-artifact@v2 @@ -35,6 +76,7 @@ jobs: linux-i386: runs-on: ubuntu-latest + needs: create-release steps: - uses: actions/checkout@v1 - name: Set up QEMU @@ -48,7 +90,7 @@ jobs: name: Build run: | chmod +x compile_linux.sh - ./compile_linux.sh 386 Release ${{ github.event.inputs.ref }} + ./compile_linux.sh 386 Release ${{ github.event.inputs.repo }} ${{ github.event.inputs.ref }} - name: Export artifacts uses: actions/upload-artifact@v2 diff --git a/.gitignore b/.gitignore index 148363c..d101038 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ out - +tools/*.txt +tools/*.md +tools/*.json diff --git a/DockerfileLinux b/DockerfileLinux index 87ec533..7da81c7 100644 --- a/DockerfileLinux +++ b/DockerfileLinux @@ -6,7 +6,8 @@ ARG BUILD_TYPE #Declare architecture argument (386 or amd64) ARG TARGETARCH -#Declare git ref +#Declare git args +ARG REPO ARG REF WORKDIR /builder diff --git a/compile_linux.sh b/compile_linux.sh index 8833741..b47fbdc 100755 --- a/compile_linux.sh +++ b/compile_linux.sh @@ -1,19 +1,20 @@ #!/bin/bash -if [ $# -lt 2 ] +if [ $# -lt 2 ] || [ $# -eq 3 ] then - echo "Usage: ./compile_linux.sh [ref]" + echo "Usage: ./compile_linux.sh [ ]" echo "" echo "architecture: the target architecture to build for. Architectures are either 386 or amd64." echo "buildType: either Release or Debug" - echo "ref: the git commit id to pull" + echo "gitrepo: git repository url to clone" + echo "gitref: the git commit id to pull" exit 1 fi #Execute buildx with linux dockerfile and output to current directory if [ $# -eq 2 ] then - docker buildx build --platform=linux/$1 --build-arg TARGETARCH=$1 --build-arg BUILD_TYPE=$2 --build-arg REF=master --file DockerfileLinux --output out . + docker buildx build --platform=linux/$1 --build-arg TARGETARCH=$1 --build-arg BUILD_TYPE=$2 --build-arg REPO=https://bitbucket.org/chromiumembedded/java-cef.git --build-arg REF=master --file DockerfileLinux --output out . else - docker buildx build --platform=linux/$1 --build-arg TARGETARCH=$1 --build-arg BUILD_TYPE=$2 --build-arg REF=$3 --file DockerfileLinux --output out . + docker buildx build --platform=linux/$1 --build-arg TARGETARCH=$1 --build-arg BUILD_TYPE=$2 --build-arg REPO=$3 --build-arg REF=$4 --file DockerfileLinux --output out . fi diff --git a/scripts/run_linux.sh b/scripts/run_linux.sh index 163ad53..fec8a8f 100644 --- a/scripts/run_linux.sh +++ b/scripts/run_linux.sh @@ -7,7 +7,7 @@ echo "Building for architecture $TARGETARCH" if [ ! -f "/jcef/README.md" ]; then echo "Did not find existing files to build - cloning..." rm -rf /jcef - git clone https://bitbucket.org/chromiumembedded/java-cef.git /jcef + git clone ${REPO} /jcef cd /jcef git checkout ${REF} else diff --git a/tools/create_release_info.sh b/tools/create_release_info.sh new file mode 100755 index 0000000..4b352be --- /dev/null +++ b/tools/create_release_info.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +if [ ! $# -eq 4 ] + then + echo "Usage: ./create_release_info.sh " + echo "" + echo "gitrepo: git repository url to clone" + echo "gitref: the git commit id to pull" + echo "actionsurl: the url pointing to the builder job" + echo "actionsrunnumber: the number of the current build" + exit 1 +fi + +#Pull from git +git clone $1 jcef +cd jcef +git checkout $2 + +#Dump git commit id and suspected url +git rev-parse HEAD | cut -c -7 > ../commit_id.txt #Use short 7-digit commit id +( + sed 's/\.git.*$//' <<< "$1" #Remove .git and everything behind from url + echo "/commits/" + git rev-parse HEAD #Add commit id +) | awk '{print}' ORS='' > ../commit_url.txt #Remove newlines and pipe to file + +#Dump git commit message +git log -1 --pretty=%B > ../commit_message.txt + +#Dump cef version info +(grep -o -P '(?<=CEF_VERSION \").*(?=\")' < CMakeLists.txt) > ../cef_version.txt + +#Build final release information +#Tag +( + echo "release_tag_name=" + echo "jcef-" + cat ../commit_id.txt + echo "+cef-" + cat ../cef_version.txt +) | awk '{print}' ORS='' >> $GITHUB_ENV + +#Name +( + echo "release_name=" + echo "JCEF " + cat ../commit_id.txt + echo " + CEF " + cat ../cef_version.txt +) | awk '{print}' ORS='' >> $GITHUB_ENV + +#Readme +( + echo "Update JCEF to [" + cat ../commit_id.txt + echo "](" + cat ../commit_url.txt + echo ")" + echo "" + echo "Build: [GitHub Actions #$4]($3)" + echo "" + echo "JCEF version:" + cat ../commit_id.txt + echo "" + echo "CEF version:" + cat ../cef_version.txt + echo "" + echo "Changes from previous release:" + echo "\`\`\`" + cat ../commit_message.txt + echo "\`\`\`" +) > ../release_message.md + +#Add LICENSE +mv LICENSE.txt .. + +#Cleanup +rm *.txt +cd .. +rm -rf jcef