mirror of
https://github.com/loot/libloot-python.git
synced 2026-07-27 14:14:13 -07:00
139 lines
4.4 KiB
YAML
139 lines
4.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
# Don't run this workflow when a tag is pushed.
|
|
branches:
|
|
- '*'
|
|
pull_request:
|
|
|
|
env:
|
|
MSVC_CONFIG: RelWithDebInfo
|
|
|
|
jobs:
|
|
# Publish to Artifactory as a separate job that runs after the build jobs
|
|
# because we must first clean out any existing artifacts for this Git ref,
|
|
# and we don't want to do that as a pre-build step in case the build fails
|
|
# and we're left with no artifacts published.
|
|
publish-to-artifactory:
|
|
runs-on: ubuntu-18.04
|
|
needs: [windows]
|
|
if: github.event_name == 'push'
|
|
|
|
steps:
|
|
- name: Clean up artifacts on Artifactory
|
|
run: |
|
|
curl -sfSLO 'https://raw.githubusercontent.com/Ortham/ci-scripts/2.2.0/remove_old_artifactory_files.py'
|
|
|
|
python3 remove_old_artifactory_files.py \
|
|
--artifactory-host loot.jfrog.io \
|
|
--artifactory-api-key ${{ secrets.ARTIFACTORY_API_KEY }} \
|
|
--artifactory-repository libloot-python \
|
|
--current-branch "${GITHUB_REF#refs/*/}" \
|
|
--github-repository loot/libloot-python \
|
|
--github-token ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Create empty directory for artifacts
|
|
run: |
|
|
rm -rf downloaded_artifacts
|
|
mkdir downloaded_artifacts
|
|
|
|
- name: Download all artifacts for this workflow from GitHub Actions
|
|
uses: actions/download-artifact@v2
|
|
with:
|
|
path: downloaded_artifacts
|
|
|
|
- name: Publish artifacts to Artifactory
|
|
shell: bash
|
|
run: |
|
|
curl -sfSLO 'https://raw.githubusercontent.com/Ortham/ci-scripts/2.2.0/percent_encode.py'
|
|
|
|
PERCENT_ENCODED_GIT_REF_NAME=$(python3 percent_encode.py "${GITHUB_REF#refs/*/}")
|
|
|
|
for ARTIFACT_DIRECTORY in downloaded_artifacts/*
|
|
do
|
|
ARTIFACT_NAME="${ARTIFACT_DIRECTORY#downloaded_artifacts/}"
|
|
PERCENT_ENCODED_ARTIFACT_NAME=$(python3 percent_encode.py "$ARTIFACT_NAME")
|
|
curl -sSfL \
|
|
-X PUT \
|
|
-T "$ARTIFACT_DIRECTORY/$ARTIFACT_NAME" \
|
|
-H "X-JFrog-Art-Api: ${{ secrets.ARTIFACTORY_API_KEY }}" \
|
|
"https://loot.jfrog.io/artifactory/libloot-python/${PERCENT_ENCODED_GIT_REF_NAME}/$PERCENT_ENCODED_ARTIFACT_NAME"
|
|
done
|
|
|
|
windows:
|
|
runs-on: windows-2016
|
|
|
|
strategy:
|
|
matrix:
|
|
platform: [Win32, x64]
|
|
python-version: [3.7]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get Python architecture
|
|
id: get-python-architecture
|
|
shell: bash
|
|
run: |
|
|
if [[ "${{ matrix.platform }}" == "Win32" ]]
|
|
then
|
|
PLATFORM=x86
|
|
else
|
|
PLATFORM=x64
|
|
fi
|
|
echo "::set-output name=architecture::$PLATFORM"
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v2
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
architecture: ${{ steps.get-python-architecture.outputs.architecture }}
|
|
|
|
- name: Get descriptive version
|
|
id: get-version
|
|
shell: bash
|
|
run: |
|
|
GIT_DESCRIBE=$(git describe --tags --long --abbrev=7)
|
|
DESC_REF=${GIT_DESCRIBE}_${GITHUB_REF#refs/*/}
|
|
SAFE_DESC_REF=${DESC_REF//[\/<>\"|]/_}
|
|
echo "::set-output name=version::$SAFE_DESC_REF"
|
|
|
|
- name: Run CMake
|
|
run: |
|
|
mkdir build
|
|
cd build
|
|
cmake .. -G "Visual Studio 15 2017" -A ${{ matrix.platform }} -DCPACK_PACKAGE_VERSION="${{ steps.get-version.outputs.version }}-python${{ matrix.python-version }}"
|
|
cmake --build . --config ${{ env.MSVC_CONFIG }}
|
|
|
|
- name: Run tests
|
|
run: |
|
|
cd build
|
|
ctest -C ${{ env.MSVC_CONFIG }}
|
|
|
|
- name: Build archive
|
|
id: build-archive
|
|
shell: bash
|
|
run: |
|
|
cd build
|
|
cpack -C ${{ env.MSVC_CONFIG }}
|
|
|
|
VERSION="${{ steps.get-version.outputs.version }}-python${{ matrix.python-version }}"
|
|
if [[ "${{ matrix.platform }}" == "Win32" ]]
|
|
then
|
|
PLATFORM=win32
|
|
else
|
|
PLATFORM=win64
|
|
fi
|
|
|
|
echo "::set-output name=filename::libloot-python-${VERSION}-${PLATFORM}.zip"
|
|
|
|
- name: Upload archive
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: ${{ steps.build-archive.outputs.filename }}
|
|
path: build/package/${{ steps.build-archive.outputs.filename }}
|
|
if: github.event_name == 'push'
|