2024-02-04 18:11:28 +00:00
|
|
|
name: Snap
|
2021-01-06 14:58:27 +00:00
|
|
|
|
|
|
|
on:
|
2024-02-04 16:59:46 +00:00
|
|
|
push:
|
|
|
|
paths-ignore:
|
|
|
|
- scripts/docker/**
|
|
|
|
branches:
|
|
|
|
- master
|
2021-01-06 14:58:27 +00:00
|
|
|
pull_request:
|
2024-01-20 12:07:33 +00:00
|
|
|
paths-ignore:
|
|
|
|
- scripts/docker/**
|
2021-01-06 14:58:27 +00:00
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
Snap:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
timeout-minutes: 60
|
|
|
|
steps:
|
|
|
|
- name: Check out code
|
2024-05-11 05:33:54 +00:00
|
|
|
uses: actions/checkout@v4
|
2021-01-06 14:58:27 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2024-05-11 05:33:54 +00:00
|
|
|
submodules: recursive
|
2021-01-06 14:58:27 +00:00
|
|
|
|
2024-05-11 05:33:54 +00:00
|
|
|
- name: set the version information
|
2024-01-05 04:44:31 +00:00
|
|
|
id: version_number
|
2024-05-11 05:33:54 +00:00
|
|
|
uses: ./.github/actions/manage-version
|
|
|
|
with:
|
|
|
|
nightly-builds-secret: ${{ secrets.NIGHTLY_BUILDS }}
|
2024-01-05 04:44:31 +00:00
|
|
|
|
|
|
|
- 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 09:12:52 +00:00
|
|
|
- name: Set up LXD
|
|
|
|
uses: canonical/setup-lxd@main
|
|
|
|
|
2021-01-06 17:06:17 +00:00
|
|
|
- name: Set up CCache
|
|
|
|
id: setup-ccache
|
|
|
|
run: |
|
|
|
|
sudo apt-get install ccache
|
2023-01-19 09:12:52 +00:00
|
|
|
mkdir -p ${HOME}/.ccache
|
2021-01-06 17:06:17 +00:00
|
|
|
ccache --max-size=2G
|
2021-02-28 07:14:46 +00:00
|
|
|
/snap/bin/lxc profile device add default ccache disk source=${HOME}/.ccache/ path=/root/.ccache
|
2021-01-06 17:06:17 +00:00
|
|
|
|
|
|
|
# Patch snapcraft.yaml to enable ccache
|
2024-05-07 07:27:42 +00:00
|
|
|
patch -p1 < .github/workflows/scripts/linux-snap.patch
|
2021-01-06 17:06:17 +00:00
|
|
|
|
|
|
|
# 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
|
2024-05-11 05:33:54 +00:00
|
|
|
echo "key=$( git merge-base origin/master $GITHUB_SHA )" >> $GITHUB_OUTPUT
|
2021-01-06 17:06:17 +00:00
|
|
|
|
|
|
|
- name: CCache
|
2023-01-19 09:56:58 +00:00
|
|
|
uses: actions/cache@v3
|
2021-01-06 17:06:17 +00:00
|
|
|
with:
|
|
|
|
key: ccache-${{ runner.os }}-${{ steps.setup-ccache.outputs.key }}
|
|
|
|
restore-keys: |
|
|
|
|
ccache-${{ runner.os }}-
|
|
|
|
path: ~/.ccache/**
|
|
|
|
|
2021-01-06 14:58:27 +00:00
|
|
|
- name: Build and verify the snap
|
2023-01-19 09:12:52 +00:00
|
|
|
uses: canonical/actions/build-snap@release
|
2021-01-06 14:58:27 +00:00
|
|
|
id: build-snap
|
2023-01-19 09:12:52 +00:00
|
|
|
with:
|
|
|
|
setup-lxd: false
|
2021-01-06 14:58:27 +00:00
|
|
|
|
2023-01-19 09:12:52 +00:00
|
|
|
- name: Clear CCache stats
|
|
|
|
run: ccache --show-stats --zero-stats
|
2021-01-06 14:58:27 +00:00
|
|
|
|
|
|
|
- name: Upload the snap
|
2024-01-05 04:44:31 +00:00
|
|
|
if: github.event_name == 'push'
|
2024-05-07 07:27:42 +00:00
|
|
|
uses: actions/upload-artifact@v4
|
2021-01-06 14:58:27 +00:00
|
|
|
with:
|
2023-01-19 09:12:52 +00:00
|
|
|
name: ${{ steps.build-snap.outputs.snap-name }}
|
|
|
|
path: ${{ steps.build-snap.outputs.snap-path }}
|
2021-01-06 14:58:27 +00:00
|
|
|
if-no-files-found: error
|