2021-01-06 14:58:27 +00: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 09:56:58 +00:00
|
|
|
uses: actions/checkout@v3
|
2021-01-06 14:58:27 +00:00
|
|
|
with:
|
|
|
|
# Needed for version determination to work
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2024-01-05 04:44:31 +00:00
|
|
|
- name: atomically create or retrieve the build number
|
|
|
|
id: version_number
|
|
|
|
if: github.event_name == 'push'
|
|
|
|
run: |
|
2024-01-09 01:58:56 +00:00
|
|
|
version=$(bash ./scripts/get-atomic-buildnr.sh ${{ github.sha }} ${{ secrets.NIGHTLY_BUILDS }} "CICD-release")
|
2024-01-05 04:44:31 +00:00
|
|
|
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 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
|
|
|
|
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 09:56:58 +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'
|
2021-01-06 14:58:27 +00:00
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
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
|