2021-01-06 15:58:27 +01:00
|
|
|
name: Linux Snap
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
Snap:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
timeout-minutes: 60
|
|
|
|
steps:
|
|
|
|
- name: Check out code
|
2023-01-19 10:56:58 +01:00
|
|
|
uses: actions/checkout@v3
|
2021-01-06 15:58:27 +01:00
|
|
|
with:
|
|
|
|
# Needed for version determination to work
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2024-01-04 20:44:31 -08:00
|
|
|
- name: atomically create or retrieve the build number
|
|
|
|
id: version_number
|
|
|
|
if: github.event_name == 'push'
|
|
|
|
run: |
|
|
|
|
cd .. # check out parallel to subsurface sources
|
|
|
|
url="https://subsurface:${{ secrets.NIGHTLY_BUILDS }}@github.com/subsurface/nightly-builds"
|
|
|
|
# the clone followed by the pointless push should verify that the password is stored in the config
|
|
|
|
# that way the script doesn't need the password
|
|
|
|
git clone -b main https://github.com/subsurface/nightly-builds
|
|
|
|
cd nightly-builds
|
|
|
|
git remote set-url origin "$url"
|
|
|
|
git push origin main
|
|
|
|
cd ..
|
|
|
|
bash -x subsurface/scripts/get-or-create-build-nr.sh ${{ github.sha }}
|
|
|
|
cp nightly-builds/latest-subsurface-buildnumber subsurface
|
|
|
|
echo "CICD-release" > subsurface/latest-subsurface-buildnumber-extension
|
|
|
|
version=$(bash subsurface/scripts/get-version)
|
|
|
|
echo "version=$version" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- name: store dummy version and build number for pull request
|
|
|
|
if: github.event_name == 'pull_request'
|
|
|
|
run: |
|
|
|
|
echo "100" > latest-subsurface-buildnumber
|
|
|
|
echo "CICD-pull-request" > latest-subsurface-buildnumber-extension
|
|
|
|
|
2023-01-19 10:12:52 +01:00
|
|
|
- name: Set up LXD
|
|
|
|
uses: canonical/setup-lxd@main
|
|
|
|
|
2021-01-06 18:06:17 +01:00
|
|
|
- name: Set up CCache
|
|
|
|
id: setup-ccache
|
|
|
|
run: |
|
|
|
|
sudo apt-get install ccache
|
2023-01-19 10:12:52 +01:00
|
|
|
mkdir -p ${HOME}/.ccache
|
2021-01-06 18:06:17 +01:00
|
|
|
ccache --max-size=2G
|
2021-02-28 08:14:46 +01:00
|
|
|
/snap/bin/lxc profile device add default ccache disk source=${HOME}/.ccache/ path=/root/.ccache
|
2021-01-06 18:06:17 +01:00
|
|
|
|
|
|
|
# Patch snapcraft.yaml to enable ccache
|
|
|
|
patch -p1 < .github/workflows/linux-snap.patch
|
|
|
|
|
|
|
|
# Find common base between master and HEAD to use as cache key.
|
|
|
|
git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules origin master
|
2023-01-19 10:56:58 +01:00
|
|
|
echo "key=$( git merge-base origin/master ${{ github.sha }} )" >> $GITHUB_OUTPUT
|
2021-01-06 18:06:17 +01:00
|
|
|
|
|
|
|
- name: CCache
|
2023-01-19 10:56:58 +01:00
|
|
|
uses: actions/cache@v3
|
2021-01-06 18:06:17 +01:00
|
|
|
with:
|
|
|
|
key: ccache-${{ runner.os }}-${{ steps.setup-ccache.outputs.key }}
|
|
|
|
restore-keys: |
|
|
|
|
ccache-${{ runner.os }}-
|
|
|
|
path: ~/.ccache/**
|
|
|
|
|
2021-01-06 15:58:27 +01:00
|
|
|
- name: Build and verify the snap
|
2023-01-19 10:12:52 +01:00
|
|
|
uses: canonical/actions/build-snap@release
|
2021-01-06 15:58:27 +01:00
|
|
|
id: build-snap
|
2023-01-19 10:12:52 +01:00
|
|
|
with:
|
|
|
|
setup-lxd: false
|
2021-01-06 15:58:27 +01:00
|
|
|
|
2023-01-19 10:12:52 +01:00
|
|
|
- name: Clear CCache stats
|
|
|
|
run: ccache --show-stats --zero-stats
|
2021-01-06 15:58:27 +01:00
|
|
|
|
|
|
|
- name: Upload the snap
|
2024-01-04 20:44:31 -08:00
|
|
|
if: github.event_name == 'push'
|
2021-01-06 15:58:27 +01:00
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
2023-01-19 10:12:52 +01:00
|
|
|
name: ${{ steps.build-snap.outputs.snap-name }}
|
|
|
|
path: ${{ steps.build-snap.outputs.snap-path }}
|
2021-01-06 15:58:27 +01:00
|
|
|
if-no-files-found: error
|