mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
6fc8310705
Make multiple improvements to the existing workflows: - create a shared custom action to deal with version number tracking and generation; - use this action to add the branch name to the version for pull request builds; - create a shared workflow for all debian-ish builds to avoid re-use by copy / paste; - remove potential security risks by eliminating the use of pre-evaluated expressions (`${{ ... }}`) inside scripts; - update outdated GitHub action versions; - improve the consistency by renaming scripts acording to have a `.sh` extension; - improve naming of generated artefacts for pull requests to include the correct version. @dirkh: Unfortunately this is potentially going to break builds when it is merged, as there is no good way to 'test' a merge build short of merging. We'll just have to deal with the fallout of it in a follow-up pull request. Signed-off-by: Michael Keller <github@ike.ch>
80 lines
2.2 KiB
YAML
80 lines
2.2 KiB
YAML
name: Snap
|
|
|
|
on:
|
|
push:
|
|
paths-ignore:
|
|
- scripts/docker/**
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
paths-ignore:
|
|
- scripts/docker/**
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
Snap:
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 60
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: recursive
|
|
|
|
- name: set the version information
|
|
id: version_number
|
|
uses: ./.github/actions/manage-version
|
|
with:
|
|
nightly-builds-secret: ${{ secrets.NIGHTLY_BUILDS }}
|
|
|
|
- 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
|
|
|
|
- name: Set up LXD
|
|
uses: canonical/setup-lxd@main
|
|
|
|
- name: Set up CCache
|
|
id: setup-ccache
|
|
run: |
|
|
sudo apt-get install ccache
|
|
mkdir -p ${HOME}/.ccache
|
|
ccache --max-size=2G
|
|
/snap/bin/lxc profile device add default ccache disk source=${HOME}/.ccache/ path=/root/.ccache
|
|
|
|
# Patch snapcraft.yaml to enable ccache
|
|
patch -p1 < .github/workflows/scripts/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
|
|
echo "key=$( git merge-base origin/master $GITHUB_SHA )" >> $GITHUB_OUTPUT
|
|
|
|
- name: CCache
|
|
uses: actions/cache@v3
|
|
with:
|
|
key: ccache-${{ runner.os }}-${{ steps.setup-ccache.outputs.key }}
|
|
restore-keys: |
|
|
ccache-${{ runner.os }}-
|
|
path: ~/.ccache/**
|
|
|
|
- name: Build and verify the snap
|
|
uses: canonical/actions/build-snap@release
|
|
id: build-snap
|
|
with:
|
|
setup-lxd: false
|
|
|
|
- name: Clear CCache stats
|
|
run: ccache --show-stats --zero-stats
|
|
|
|
- name: Upload the snap
|
|
if: github.event_name == 'push'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ steps.build-snap.outputs.snap-name }}
|
|
path: ${{ steps.build-snap.outputs.snap-path }}
|
|
if-no-files-found: error
|