Skip to content

Bump actions/download-artifact from 3 to 4 #190

Bump actions/download-artifact from 3 to 4

Bump actions/download-artifact from 3 to 4 #190

Workflow file for this run

name: 'Build'
on:
pull_request:
push:
branches:
- 'master'
tags:
- 'v*'
workflow_dispatch:
env:
GRADLE_OPTS: -Dorg.gradle.daemon=true -Dorg.gradle.parallel=true -Dorg.gradle.welcome=never
GPG_SEC: ${{ secrets.PGP_SEC }}
GPG_PASSWORD: ${{ secrets.PGP_PASSWORD }}
jobs:
build-native:
name: 'Build native code (${{ matrix.jna-os }}-${{ matrix.jna-arch }})'
runs-on: ${{ matrix.os }}
env:
CC: gcc
CXX: g++
CFLAGS: ${{ matrix.cflags }}
CXXFLAGS: ${{ matrix.cflags }}
CMAKE_BUILD_TYPE: Release
CMAKE_COLOR_DIAGNOSTICS: ON
strategy:
fail-fast: false
matrix:
jna-os: [ linux, win32, darwin ]
jna-arch: [ x86, x86-64 ]
include:
- os: ubuntu-latest
jna-os: linux
- os: windows-latest
jna-os: win32
- os: macos-13
jna-os: darwin
- arch: x86
jna-arch: x86
cflags: '-m32'
- arch: x64
jna-arch: x86-64
cflags: '-m64'
exclude:
- jna-os: darwin
jna-arch: x86
steps:
- name: 'Set up GCC'
if: ${{ runner.os == 'Linux' }}
uses: egor-tensin/setup-gcc@v1
with:
version: latest
platform: ${{ matrix.arch }}
- name: 'Set up MinGW'
id: 'mingw'
if: ${{ runner.os == 'Windows' && matrix.arch == 'x86' }}
uses: egor-tensin/setup-mingw@v2
with:
platform: ${{ matrix.arch }}
version: 12.2.0
- name: 'Set up MinGW environment'
if: ${{ runner.os == 'Windows' }}
run: |
if [[ '${{ steps.mingw.outcome }}' == 'success' ]]
then
echo 'CC=${{ steps.mingw.outputs.gcc }}' >>${GITHUB_ENV}
echo 'CXX=${{ steps.mingw.outputs.gxx }}' >>${GITHUB_ENV}
elif [[ '${{ matrix.arch }}' == 'x86' ]]
then
echo 'CC=i686-w64-mingw32-gcc' >>${GITHUB_ENV}
echo 'CXX=i686-w64-mingw32-g++' >>${GITHUB_ENV}
else
echo 'CC=x86_64-w64-mingw32-gcc' >>${GITHUB_ENV}
echo 'CXX=x86_64-w64-mingw32-g++' >>${GITHUB_ENV}
fi
echo 'CMAKE_GENERATOR=MinGW Makefiles' >>${GITHUB_ENV}
shell: bash
- name: 'Set up CMake'
uses: lukka/get-cmake@latest
- name: 'Report tool versions'
run: |
echo '| `arch` | `uname -m` | CMake Version | GCC | GCC Version | GCC Target Architecture |' >>${GITHUB_STEP_SUMMARY}
echo '|--------|------------|---------------|-----|-------------|-------------------------|' >>${GITHUB_STEP_SUMMARY}
echo "|$(arch)|$(uname -m)|$(cmake --version | head -n1)|$(which "${CC}")|$("${CC}" --version | head -n1)|$("${CC}" -dumpmachine)|" >>${GITHUB_STEP_SUMMARY}
shell: bash
- uses: actions/checkout@v4
with:
submodules: recursive
- name: 'Build libtree-sitter.so'
if: ${{ runner.os != 'Windows' }}
run: |
cmake -S jna-lib/tree-sitter/ -B jna-lib/tree-sitter/build/
cmake --build jna-lib/tree-sitter/build/
shell: bash
- name: 'Build tree-sitter.dll'
if: ${{ runner.os == 'Windows' }}
# MinGW builds require `mingw-w64-{i686,x86_64}-icu` (`unicode/umachine.h`)
# which is not installed by default.
# In the future, we'll try to resolve this by using the `msys2/setup-msys2` Action.
continue-on-error: true
run: |
cmake -S jna-lib/tree-sitter/ -B jna-lib/tree-sitter/build/
cmake --build jna-lib/tree-sitter/build/
shell: bash
- name: 'Build libtree-sitter-cpp.so'
run: |
cmake -S jna-lib/tree-sitter-cpp/ -B jna-lib/tree-sitter-cpp/build/
cmake --build jna-lib/tree-sitter-cpp/build/
shell: bash
- name: 'Upload native libraries (libtree-sitter.so)'
if: ${{ runner.os != 'Windows' }}
uses: actions/upload-artifact@v4
with:
name: 'libtree-sitter-${{ matrix.jna-os }}-${{ matrix.jna-arch }}'
path: |
jna-lib/tree-sitter/build/libtree-sitter*.so*
jna-lib/tree-sitter/build/libtree-sitter*.dylib
if-no-files-found: error
retention-days: 1
- name: 'Upload native libraries (tree-sitter.dll)'
if: ${{ runner.os == 'Windows' }}
uses: actions/upload-artifact@v4
with:
name: 'libtree-sitter-${{ matrix.jna-os }}-${{ matrix.jna-arch }}'
path: |
jna-lib/tree-sitter/build/tree-sitter*.dll
retention-days: 1
# We put each file into the artifact separately, so that internal
# directory structure remains flat (no relative paths get stored).
- name: 'Upload native libraries (libtree-sitter-cpp.so)'
uses: actions/upload-artifact@v4
with:
name: 'libtree-sitter-${{ matrix.jna-os }}-${{ matrix.jna-arch }}'
path: |
jna-lib/tree-sitter-cpp/build/libtree-sitter*.so*
jna-lib/tree-sitter-cpp/build/libtree-sitter*.dylib
jna-lib/tree-sitter-cpp/build/tree-sitter*.dll
if-no-files-found: error
retention-days: 1
test:
name: 'Run unit tests (${{ matrix.jna-os }}-${{ matrix.jna-arch }})'
runs-on: ${{ matrix.os }}
needs: build-native
strategy:
fail-fast: false
matrix:
jna-os: [ linux, win32, darwin ]
jna-arch: [ x86, x86-64 ]
include:
- os: ubuntu-latest
jna-os: linux
- os: windows-latest
jna-os: win32
- os: macos-13
jna-os: darwin
- arch: x86
jna-arch: x86
- arch: x64
jna-arch: x86-64
exclude:
- jna-os: darwin
jna-arch: x86
# `tree-sitter-cpp.dll` depends on `libstdc++` and `libgcc_s`.
# Any attempts to load it fail with an `UnsatisfiedLinkError`
# whenever `mingw{32,64}\bin` is not in `PATH`.
#
# Until we start linking against `libstdc++` statically,
# disable tests on `win32-x86`.
- jna-os: win32
jna-arch: x86
# A possible workaround for <https://github.com/dorny/test-reporter/issues/168>.
permissions:
checks: write
contents: write
pull-requests: write
statuses: write
steps:
- uses: actions/checkout@v4
with:
# Fetch Git tags, so that semantic version can be calculated.
# Alternatively, run `git fetch --prune --unshallow --tags` as the
# next step, see
# https://github.com/actions/checkout/issues/206#issuecomment-607496604.
fetch-depth: 0
- name: 'Download native libraries'
uses: actions/download-artifact@v4
with:
name: 'libtree-sitter-${{ matrix.jna-os }}-${{ matrix.jna-arch }}'
path: jna-lib/src/main/resources/${{ matrix.jna-os }}-${{ matrix.jna-arch }}/
- name: 'Strip version information from file names'
if: ${{ runner.os != 'Windows' }}
run: |
for file in $(find jna-lib/src/main/resources/${{ matrix.jna-os }}-${{ matrix.jna-arch }}/ -type f \( -name 'lib*.so*' -o -name 'lib*.dylib' \))
do
old_file="$(basename "${file}")"
new_file="$(echo "${old_file}" | sed -n '/^lib..*\.[0-9]..*/s/\.[0-9][0-9]*//gp')"
if [[ "${old_file}" != "${new_file}" ]]
then
echo "mv ${file} $(dirname ${file})/${new_file}"
mv -v "${file}" "$(dirname "${file}")/${new_file}"
fi
done
shell: bash
- name: 'Set POSIX attributes'
if: ${{ runner.os != 'Windows' }}
run: |
find jna-lib/src/main/resources/${{ matrix.jna-os }}-${{ matrix.jna-arch }}/ -type f \( -name 'lib*.so' -o -name 'lib*.dylib' \) -exec chmod 755 '{}' ';'
find jna-lib/src/main/resources/${{ matrix.jna-os }}-${{ matrix.jna-arch }}/ -type f \( -name 'lib*.so' -o -name 'lib*.dylib' \) -exec ls -lF --color=always '{}' ';'
shell: bash
- name: 'Set up Java 11'
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 11
java-package: 'jdk+fx'
architecture: ${{ matrix.arch }}
- name: 'Run unit tests'
id: test
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
arguments: |
--continue
build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
name: 'Publish packages'
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
runs-on: ubuntu-latest
needs: build-native
permissions:
# Explicitly granted, necessary for the `publish` step.
packages: write
steps:
- uses: actions/checkout@v4
with:
# Fetch Git tags, so that semantic version can be calculated.
# Alternatively, run `git fetch --prune --unshallow --tags` as the
# next step, see
# https://github.com/actions/checkout/issues/206#issuecomment-607496604.
fetch-depth: 0
- name: 'Download native libraries (darwin-x86-64)'
uses: actions/download-artifact@v4
with:
name: 'libtree-sitter-darwin-x86-64'
path: jna-lib/src/main/resources/darwin-x86-64/
- name: 'Download native libraries (linux-x86)'
uses: actions/download-artifact@v4
with:
name: 'libtree-sitter-linux-x86'
path: jna-lib/src/main/resources/linux-x86/
- name: 'Download native libraries (linux-x86-64)'
uses: actions/download-artifact@v4
with:
name: 'libtree-sitter-linux-x86-64'
path: jna-lib/src/main/resources/linux-x86-64/
- name: 'Download native libraries (win32-x86)'
uses: actions/download-artifact@v4
with:
name: 'libtree-sitter-win32-x86'
path: jna-lib/src/main/resources/win32-x86/
- name: 'Download native libraries (win32-x86-64)'
uses: actions/download-artifact@v4
with:
name: 'libtree-sitter-win32-x86-64'
path: jna-lib/src/main/resources/win32-x86-64/
- name: 'Strip version information from file names'
if: ${{ runner.os != 'Windows' }}
run: |
for file in $(find jna-lib/src/main/resources/ -type f \( -name 'lib*.so*' -o -name 'lib*.dylib' \))
do
old_file="$(basename "${file}")"
new_file="$(echo "${old_file}" | sed -n '/^lib..*\.[0-9]..*/s/\.[0-9][0-9]*//gp')"
if [[ "${old_file}" != "${new_file}" ]]
then
echo "mv ${file} $(dirname ${file})/${new_file}"
mv -v "${file}" "$(dirname "${file}")/${new_file}"
fi
done
shell: bash
- name: 'Set POSIX attributes'
if: ${{ runner.os != 'Windows' }}
run: |
find jna-lib/src/main/resources/ -type f \( -name 'lib*.so' -o -name 'lib*.dylib' \) -exec chmod 755 '{}' ';'
find jna-lib/src/main/resources/ -type f \( -name 'lib*.so' -o -name 'lib*.dylib' \) -exec ls -lF --color=always '{}' ';'
shell: bash
- name: 'Set up Java 11'
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 11
java-package: 'jdk+fx'
- name: 'Publish a release'
id: publish
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
arguments: |
-x test
build
publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
report:
name: 'Publish JUnit test results (${{ matrix.jna-os }}-${{ matrix.jna-arch }})'
if: ${{ always() }}
needs: test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
jna-os: [ linux, win32, darwin ]
jna-arch: [ x86, x86-64 ]
exclude:
- jna-os: darwin
jna-arch: x86
- jna-os: win32
jna-arch: x86
permissions:
checks: write
pull-requests: write
steps:
# Uses Docker, that's why Linux-only.
- name: 'JUnit Tests (EnricoMi/publish-unit-test-result-action)'
run: |
echo ''
shell: bash