Skip to content

Build

Build #501

Workflow file for this run

# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: Build
on:
push:
branches-ignore: # build all branches except:
- 'dependabot/**' # prevent GHA triggered twice (once for commit to the branch and once for opening/syncing the PR)
tags-ignore: # don't build tags
- '**'
paths-ignore:
- '**/*.adoc'
- '**/*.md'
- '.editorconfig'
- '.git*'
- '.github/*.yml'
pull_request:
paths-ignore:
- '**/*.adoc'
- '**/*.md'
- '.editorconfig'
- '.git*'
- '.github/*.yml'
repository_dispatch:
types: [new-haxe4e-release]
workflow_dispatch:
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
inputs:
additional_maven_args:
description: 'Additional Maven Args'
required: false
default: ''
defaults:
run:
shell: bash
env:
JAVA_VERSION: 17
jobs:
build:
runs-on: windows-latest
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'repository_dispatch' }}
steps:
- name: Show environment variables
run: env | sort
- name: Git Checkout
uses: actions/checkout@v4 # https://github.com/actions/checkout
- name: "Install: JDK ${{ env.JAVA_VERSION }}"
uses: actions/setup-java@v4 # https://github.com/actions/setup-java
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
- name: "Cache: Restore"
id: cache-restore
if: ${{ !env.ACT }} # https://github.com/nektos/act#skipping-steps
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
!~/.m2/repository/.cache/tycho/https/raw.githubusercontent.com
!~/.m2/repository/*SNAPSHOT*
key: ${{ runner.os }}-${{ hashFiles('build.target') }}-${{ hashFiles('**/pom.xml') }}
- name: "Install: Maven"
uses: stCarolas/[email protected] # https://github.com/stCarolas/setup-maven
with:
maven-version: 3.9.6
- name: Build with Maven
id: maven-build
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_API_KEY: ${{ github.token }}
run: |
set -eu
# https://github.community/t/github-actions-bot-email-address/17204
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
MAVEN_OPTS="${MAVEN_OPTS:-}"
MAVEN_OPTS="$MAVEN_OPTS -XX:+TieredCompilation -XX:TieredStopAtLevel=1" # https://zeroturnaround.com/rebellabs/your-maven-build-is-slow-speed-it-up/
MAVEN_OPTS="$MAVEN_OPTS -Djava.security.egd=file:/dev/./urandom" # https://stackoverflow.com/questions/58991966/what-java-security-egd-option-is-for/59097932#59097932
MAVEN_OPTS="$MAVEN_OPTS -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS" # https://stackoverflow.com/questions/5120470/how-to-time-the-different-stages-of-maven-execution/49494561#49494561
MAVEN_OPTS="$MAVEN_OPTS -Xmx1024m -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dhttps.protocols=TLSv1.2"
echo " -> MAVEN_OPTS: $MAVEN_OPTS"
export MAVEN_OPTS
mvn \
--errors \
--update-snapshots \
--batch-mode \
--show-version \
--no-transfer-progress \
-s .ci/maven-settings.xml \
-t .ci/maven-toolchains.xml \
-Dtycho.disableP2Mirrors=true \
${{ github.event.inputs.additional_maven_args }} \
clean verify
python product/fix_exec_flag_in_archives.py
mv product/target/products/org.haxe4e.studio-win32.win32.x86_64.zip \
product/target/products/org.haxe4e.studio-win.x86_64.zip
- name: Generate PortableApps archive
run: |
bash product/build-paf.sh
- name: "Delete previous 'latest' release"
if: ${{ github.ref_name == 'main' && !env.ACT }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NAME: latest
# https://cli.github.com/manual/gh_release_delete
run: |
GH_DEBUG=1 gh release delete "$RELEASE_NAME" --yes --cleanup-tag || true
- name: "Create 'latest' release"
if: ${{ github.ref_name == 'main' && !env.ACT }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NAME: latest
# https://cli.github.com/manual/gh_release_create
run: |
GH_DEBUG=1 gh release create "$RELEASE_NAME" \
--title "$RELEASE_NAME" \
--latest \
--notes "${{ github.event.head_commit.message }}" \
--target "${{ github.sha }}" \
product/target/products/org.haxe4e.studio-linux.gtk.x86_64.tar.gz \
product/target/products/org.haxe4e.studio-macosx.cocoa.x86_64.tar.gz \
product/target/products/org.haxe4e.studio-win.x86_64.zip \
product/target/HaxeStudioPortable.paf.exe
- name: Deploy p2 update site
if: ${{ github.ref_name == 'main' && !env.ACT }}
run: |
set -eux
last_commit_message=$(git log --pretty=format:"%s (%h)" -1)
cd /tmp
github_repo_url="https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}"
if curl --output /dev/null --silent --head --fail "$github_repo_url/tree/updatesite"; then
git clone $github_repo_url --single-branch --branch updatesite updatesite
cd updatesite
# https://github.community/t/github-actions-bot-email-address/17204
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git reset --hard HEAD^
else
git clone $github_repo_url updatesite
cd updatesite
git checkout --orphan updatesite
git rm -rf .
cat <<EOF > index.html
<!DOCTYPE html>
<html>
<head>
<title>${{ github.repository }} - Update Site</title>
</head>
<body>
<h1>${{ github.repository }} - Update Site</h1>
</body>
</html>
EOF
git add index.html
# https://github.community/t/github-actions-bot-email-address/17204
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -am "Initialize Update Site"
fi
mv $(cygpath $GITHUB_WORKSPACE)/product/target/repository/* .
git add --all
git commit -am "$last_commit_message"
git push origin updatesite --force
##################################################
# Cache Update
# See https://github.com/actions/cache/issues/342
##################################################
- name: "Cache: Delete Previous"
if: ${{ steps.cache-restore.outputs.cache-hit && !env.ACT }}
env:
GH_TOKEN: ${{ github.token }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ steps.cache-restore.outputs.cache-primary-key }} --confirm || true
- name: "Cache: Update"
uses: actions/cache/save@v4
if: ${{ always() && !cancelled() && !env.ACT }} # save cache even fails
with:
path: |
~/.m2/repository
!~/.m2/repository/.cache/tycho/https/raw.githubusercontent.com
!~/.m2/repository/*SNAPSHOT*
key: ${{ steps.cache-restore.outputs.cache-primary-key }}