Skip to content

Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows #175

Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows

Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows #175

name: Java and Natives
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
# Java version to use for the release
RELEASE_JAVA_VERSION: 11
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
version:
name: Prepare version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
create_tag: ${{ steps.version.outputs.create_tag }}
tag_name: ${{ steps.version.outputs.tag_name }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ env.RELEASE_JAVA_VERSION }}
distribution: temurin
# don't use the setup-java cache option as this only caches what is
# necessary for the version, not the other jobs
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-version-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-version-
- name: Parse and set version
id: version
run: |
MVNVER=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`
if [ "$GITHUB_REF" == "refs/heads/master" ]; then
TAG_NAME="v${MVNVER/-SNAPSHOT/}"
if ! git rev-parse "$TAG_NAME" >/dev/null 2>&1
then
echo "Creating tag $TAG_NAME"
git config --local user.name "$GITHUB_ACTOR via GitHub Actions"
git config --local user.email "[email protected]"
git tag -a "$TAG_NAME" -m "Tagged automatically by GitHub Actions ${{ github.workflow }}"
echo "::set-output name=create_tag::true"
else
echo "Tag: $TAG_NAME already exists"
echo "::set-output name=create_tag::false"
fi
VERSION=`git describe --match "v[0-9\.]*" --long --always`
VERSION=${VERSION:1}
else
echo "Not on master"
echo "::set-output name=create_tag::false"
VERSION=${MVNVER}
fi
echo "Version: $VERSION"
echo "::set-output name=version::${VERSION}"
echo "::set-output name=tag_name::${TAG_NAME}"
javatest:
name: Java ${{ matrix.java }}
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 11, 17 ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin
cache: maven
- name: Build and test with Maven
run: mvn -B verify -DperformRelease=true
- name: Upload JNI headers
if: matrix.java == env.RELEASE_JAVA_VERSION
uses: actions/upload-artifact@v3
with:
name: javah
path: target/native
deb:
runs-on: ubuntu-latest
needs:
- version
- javatest
strategy:
fail-fast: false
matrix:
dist:
- { vendor: ubuntu, dist: bionic }
- { vendor: ubuntu, dist: focal }
- { vendor: ubuntu, dist: jammy }
- { vendor: debian, dist: buster }
- { vendor: debian, dist: bullseye }
arch:
- amd64
- arm64
- ppc64el
include: [
# crossbuild-essential-i386 is missing on bionic, failing sbuild
# { dist: { vendor: ubuntu, dist: bionic }, arch: i386 },
{ dist: { vendor: debian, dist: buster }, arch: i386 },
{ dist: { vendor: debian, dist: bullseye }, arch: i386 },
]
name: ${{ matrix.dist.dist }} ${{ matrix.arch }}
env:
UBUNTUTOOLS_UBUNTU_MIRROR: http://azure.archive.ubuntu.com/ubuntu
UBUNTUTOOLS_DEBIAN_MIRROR: http://debian-archive.trafficmanager.net/debian/
UBUNTUTOOLS_DEBSEC_MIRROR: http://debian-archive.trafficmanager.net/debian-security
DEBIAN_FRONTEND: noninteractive
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Java
uses: actions/setup-java@v3
with:
java-version: ${{ env.RELEASE_JAVA_VERSION }}
distribution: temurin
cache: maven
- name: Get JNI headers
uses: actions/[email protected]
with:
name: javah
path: target/native
- name: Import GPG key
env:
GPG_PASSPHRASE: "${{ secrets.GPG_PW }}"
run: |
cat <(echo -e "${{ secrets.GPG_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- name: Cache sbuild chroot stanza
uses: actions/cache@v3
id: chroot_cache
with:
path: target/chroot
key: chroot-${{ matrix.dist.dist }}-${{ matrix.arch }}-${{ hashFiles('target/chroot/**') }}
restore-keys: |
chroot-${{ matrix.dist.dist }}-${{ matrix.arch }}-
- name: Move chroot from cache
if: steps.chroot_cache.outputs.cache-hit
run: |
sudo mkdir -p /var/lib/schroot/tarballs/
sudo mkdir -p /etc/schroot/chroot.d/
sudo mv target/chroot/tarballs/* /var/lib/schroot/tarballs/
sudo mv target/chroot/chroot.d/* /etc/schroot/chroot.d/
sudo chown -R root:root /var/lib/schroot/tarballs/
sudo chown -R root:root /etc/schroot/chroot.d/
- name: Install tools
run: resources/deb-prepare.sh
- name: Build deb package
# the user executing sbuild needs to be in the group sbuild, a relogin is not possible here
# bionic doesn't have /bin and /usr/bin merged, thus /bin/bash
shell: /usr/bin/sg sbuild -c "/bin/bash -e {0}"
env:
GPG_PASSPHRASE: "${{ secrets.GPG_PW }}"
run: |
resources/deb-build.sh \
"${{ needs.version.outputs.version }}" \
"${{ matrix.dist.dist }}" \
"${{ matrix.arch }}"
- name: Upload packages as artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.dist.vendor }}-${{ matrix.dist.dist }}-${{ matrix.arch }}
path: target/debian/${{ matrix.dist.dist }}/*
- name: Archive chroot for cache
run: |
mkdir -p target/chroot
sudo mv /var/lib/schroot/tarballs/ target/chroot
sudo mv /etc/schroot/chroot.d/ target/chroot
sudo chown -R runner:runner target/chroot
windows:
name: Windows ${{ matrix.arch}} Natives
runs-on: windows-latest
needs: javatest
strategy:
fail-fast: false
matrix:
arch:
#- x86
- x64
steps:
- name: Expand architecture
id: expand_arch
shell: bash
run: |
if [ "${{ matrix.arch }}" == "x86" ]; then
echo "::set-output name=jitsi_arch::x86"
echo "::set-output name=msystem::MINGW32"
echo "::set-output name=mingw_arch::i686"
else
echo "::set-output name=jitsi_arch::x86-64"
echo "::set-output name=msystem::MINGW64"
echo "::set-output name=mingw_arch::x86_64"
fi;
- name: Checkout
uses: actions/checkout@v3
- name: Get JNI headers
uses: actions/[email protected]
with:
name: javah
path: target/native
- name: Install Java
id: install_java
uses: actions/setup-java@v3
with:
java-version: ${{ env.RELEASE_JAVA_VERSION }}
architecture: ${{ matrix.arch }}
distribution: temurin
cache: maven
- name: Install MSYS2 packages
uses: msys2/setup-msys2@v2
with:
msystem: ${{ steps.expand_arch.outputs.msystem }}
install: >-
diffutils
git
make
mingw-w64-${{ steps.expand_arch.outputs.mingw_arch }}-toolchain
mingw-w64-${{ steps.expand_arch.outputs.mingw_arch }}-cmake
mingw-w64-${{ steps.expand_arch.outputs.mingw_arch }}-pkg-config
nasm
pkg-config
yasm
- name: Build natives
shell: msys2 {0}
run: |
cmake -B cmake-build-${{ matrix.arch}} -G "MinGW Makefiles" -DJAVA_HOME=${JAVA_HOME//\\/\/}
cmake --build cmake-build-${{ matrix.arch}} --config Release --target install
- name: Upload natives
uses: actions/upload-artifact@v3
with:
name: win32-${{ steps.expand_arch.outputs.jitsi_arch }}
path: src/main/resources/win32-*/*
mac:
runs-on: macos-latest
needs: javatest
strategy:
fail-fast: false
matrix:
arch:
- x86_64
- arm64
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get JNI headers
uses: actions/[email protected]
with:
name: javah
path: target/native
- name: Install Java
id: install_java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: ${{ env.RELEASE_JAVA_VERSION }}
architecture: ${{ matrix.arch }}
- name: Build natives
run: |
brew install yasm
brew install nasm
curl https://raw.githubusercontent.com/FFmpeg/gas-preprocessor/898e8a7f573e22ada07f8db2b87e97078787db75/gas-preprocessor.pl --output ~/gas-preprocessor.pl
chmod +x ~/gas-preprocessor.pl
sudo mv ~/gas-preprocessor.pl /usr/local/bin/
resources/mac-cmake.sh ${{ steps.install_java.outputs.path }} ${{ matrix.arch }}
- name: Upload natives
uses: actions/upload-artifact@v3
with:
name: darwin-${{ matrix.arch }}
path: src/main/resources/darwin-*/*
release:
if: github.ref == 'refs/heads/master'
needs:
- version
- deb
- windows
- mac
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ env.RELEASE_JAVA_VERSION }}
distribution: temurin
cache: maven
server-id: ossrh
server-username: SONATYPE_USER
server-password: SONATYPE_PW
- name: Download binaries
uses: actions/[email protected]
with:
path: target
- name: Copy natives for Maven
run: |
ls -aR
BASEDIR=$(pwd)/src/main/resources
mkdir -p $BASEDIR
cd target
for dist in */*/ ; do
last_dir=$(basename $dist)
if [[ "$last_dir" =~ ^(darwin|win32) ]]; then
mkdir -p "$BASEDIR/$last_dir" || true
cp "$dist"/*.{dylib,dll} "$BASEDIR/$last_dir" || true
fi;
done;
- name: Release to Maven Central
env:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PW: ${{ secrets.SONATYPE_PW }}
run: |
cat <(echo -e "${{ secrets.GPG_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
mvn -B versions:set -DnewVersion=${{ needs.version.outputs.version }} -DgenerateBackupPoms=false
mvn \
--no-transfer-progress \
--batch-mode \
-Dgpg.passphrase="${{ secrets.GPG_PW }}" \
-Dmultiplatform=true \
-DperformRelease=true \
-Drelease=true \
-DskipTests \
deploy
- name: Pack all debs to avoid Github filename mangling
run: |
tar -cvf debian-releases.tar target/{debian-*,ubuntu-*}/*
- name: Create release
uses: ncipollo/release-action@40bb172bd05f266cf9ba4ff965cb61e9ee5f6d01
with:
artifacts: "target/*.jar,debian-releases.tar"
allowUpdates: true
prerelease: true
draft: false
tag: r${{ needs.version.outputs.version }}
omitBody: true
removeArtifacts: true
replacesArtifacts: true
token: ${{ secrets.GITHUB_TOKEN }}
artifactErrorsFailBuild: true
- name: Tag
if: needs.version.outputs.create_tag == 'true'
run: |
git config --local user.name "$GITHUB_ACTOR via GitHub Actions"
git config --local user.email "[email protected]"
git tag -a "${{ needs.version.outputs.tag_name }}" -m "Tagged automatically by GitHub Actions ${{ github.workflow }}"
git push origin "${{ needs.version.outputs.tag_name }}"
deploy:
name: Deploy Debian packages
needs:
- version
- release
uses: ./.github/workflows/deploy-debian.yml
with:
release_type: unstable
tag: r${{ needs.version.outputs.version }}
secrets: inherit