tdesktop/.github/workflows/snap.yml

104 lines
2.7 KiB
YAML
Raw Normal View History

2020-01-25 05:44:58 +00:00
name: Snap.
on:
push:
paths-ignore:
- 'docs/**'
- '**.md'
2020-01-25 05:44:58 +00:00
pull_request:
paths-ignore:
- 'docs/**'
- '**.md'
2020-01-25 05:44:58 +00:00
jobs:
linux:
name: Ubuntu 18.04
runs-on: ubuntu-18.04
env:
UPLOAD_ARTIFACT: "false"
ONLY_CACHE: "false"
2020-04-24 20:26:51 +00:00
MANUAL_CACHING: "5"
2020-01-25 05:44:58 +00:00
steps:
- name: Clone.
2020-03-20 16:32:06 +00:00
uses: actions/checkout@v2
2020-01-25 05:44:58 +00:00
with:
submodules: recursive
- name: First set up.
run: |
sudo apt-get update
sudo apt-get install gcc-8 g++-8 -y
sudo snap install --classic snapcraft
# Workaround for snapcraft
2020-03-20 20:26:04 +00:00
# See https://forum.snapcraft.io/t/13258
2020-01-25 05:44:58 +00:00
sudo chown root:root /
2020-03-20 20:26:04 +00:00
md5() {
md5cache=$(md5sum $1.txt | cut -c -32)
echo ::set-env name=$1::$md5cache
}
keyFor() {
keyName="${1^^}_CACHE_KEY"
awk -v RS="" -v ORS="\n\n" '/^ '"$1"':/' snap/snapcraft.yaml > $keyName.txt
md5 $keyName
}
2020-04-18 17:30:36 +00:00
snap run snapcraft --version > CACHE_KEY.txt
2020-01-25 05:44:58 +00:00
gcc-8 --version >> CACHE_KEY.txt
echo $MANUAL_CACHING >> CACHE_KEY.txt
2020-03-20 20:26:04 +00:00
md5 CACHE_KEY
2020-01-25 05:44:58 +00:00
2020-03-20 20:26:04 +00:00
keyFor cmake
keyFor ffmpeg
2020-03-09 07:11:12 +00:00
2020-01-25 05:44:58 +00:00
- name: CMake cache.
id: cache-cmake
uses: actions/cache@v1
with:
path: parts/cmake
key: ${{ runner.OS }}-cmake-${{ env.CACHE_KEY }}-${{ env.CMAKE_CACHE_KEY }}
- name: CMake build.
if: steps.cache-cmake.outputs.cache-hit != 'true'
2020-04-18 17:30:36 +00:00
run: sudo snap run snapcraft build --destructive-mode cmake
2020-01-25 05:44:58 +00:00
2020-03-09 07:11:12 +00:00
- name: FFmpeg cache.
id: cache-ffmpeg
uses: actions/cache@v1
with:
path: parts/ffmpeg
key: ${{ runner.OS }}-ffmpeg-${{ env.CACHE_KEY }}-${{ env.FFMPEG_CACHE_KEY }}
- name: FFmpeg build.
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
2020-04-18 17:30:36 +00:00
run: sudo snap run snapcraft build --destructive-mode ffmpeg
2020-03-09 07:11:12 +00:00
2020-01-25 05:44:58 +00:00
- name: Telegram Desktop snap build.
if: env.ONLY_CACHE == 'false'
2020-04-18 17:30:36 +00:00
run: sudo snap run snapcraft --destructive-mode
2020-01-25 05:44:58 +00:00
- name: Move artifact.
if: env.UPLOAD_ARTIFACT == 'true'
run: |
artifact_name=$(echo telegram-desktop_*.snap)
echo ::set-env name=ARTIFACT_NAME::$artifact_name
mkdir artifact
mv $artifact_name artifact
- uses: actions/upload-artifact@master
if: env.UPLOAD_ARTIFACT == 'true'
name: Upload artifact.
with:
name: ${{ env.ARTIFACT_NAME }}
path: artifact
- name: Remove unneeded directories for cache.
run: |
2020-04-18 17:30:36 +00:00
sudo rm -rf parts/*/{build,src,ubuntu}
sudo rm -rf parts/*/state/{stage,prime}