generated from TheEvilSkeleton/flatpak-remote
-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (137 loc) · 5.47 KB
/
flatpak.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Based on https://raw.githubusercontent.com/gasinvein/proton-flatpak/7962b87cf0d079998ea861e1a358fa93d63af7e5/.github/workflows/flatpak.yml
name: Flatpak
on:
push:
branches:
- main
workflow_dispatch:
env:
APP_ID: org.tenacityaudio.Tenacity # App ID (reverse-DNS)
MANIFEST_PATH: org.tenacityaudio.Tenacity.yaml # Path to manifest
IMAGE_NAME: tenacity # Name of Docker image
IMAGE_TAG: nightly # Tag of image
FLATPAK_BUNDLE: tenacity # Name of bundle (excl. .flatpak)
FLATPAK_BRANCH: nightly # Flatpak branch
FLATPAK_BUILD_DIR: build-dir
FLATPAK_BUILD_REPO: build-repo
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install flatpak-builder
run: |
set -e
sudo apt update -y
sudo apt install -y flatpak-builder
- name: Dump canonical manifest
run: |
set -e
flatpak-builder --show-manifest ${MANIFEST_PATH} > canonical-manifest.json
- name: Download flatpak SDK and sources
run: |
set -e
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak-builder --default-branch=${FLATPAK_BRANCH} --install-deps-from=flathub --install-deps-only --user /dev/null ${MANIFEST_PATH}
flatpak-builder --default-branch=${FLATPAK_BRANCH} --download-only /dev/null ${MANIFEST_PATH}
- name: Prime cache
uses: actions/cache@v3
with:
path: |
.flatpak-builder/ccache
key: flatpak-builder-${{ hashFiles('canonical-manifest.json') }}
restore-keys: |
flatpak-builder-
# In Ubuntu, Git no longer allows you to add a submodule via file:///
# transport. As a fix, run git config --global protocol.file.allow always
- name: Fix Git
run: |
git config --global protocol.file.allow always
- name: Build flatpak
run: |
set -e
flatpak-builder --default-branch=${FLATPAK_BRANCH} --disable-updates --disable-download --ccache --sandbox --repo=${FLATPAK_BUILD_REPO} ${FLATPAK_BUILD_DIR} ${MANIFEST_PATH}
- name: Upload flatpak repo
uses: actions/upload-artifact@v3
with:
name: ${{ env.FLATPAK_BUILD_REPO }}
path: ${{ env.FLATPAK_BUILD_REPO }}
publish-bundle:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Install flatpak
run: |
set -e
sudo apt update -y
sudo apt install -y flatpak
- name: Download flatpak repo
uses: actions/download-artifact@v3
with:
name: ${{ env.FLATPAK_BUILD_REPO }}
- name: Create flatpak bundle
run: |
set -e
mkdir -p ${FLATPAK_BUILD_REPO}/{extensions,refs/{mirrors,remotes},state,tmp/cache}
flatpak build-bundle --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo ${FLATPAK_BUILD_REPO} ${FLATPAK_BUNDLE}.flatpak ${APP_ID} ${FLATPAK_BRANCH}
- name: Upload flatpak bundle
uses: actions/upload-artifact@v3
with:
name: ${{ env.FLATPAK_BUNDLE }}
path: ${{ env.FLATPAK_BUNDLE }}.flatpak
publish-oci:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Install flatpak and libcontainers tools
run: |
set -e
. /etc/os-release
sudo sh -c "echo 'deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list"
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key | sudo apt-key add -
sudo apt update -y
sudo apt install -y skopeo flatpak jq
- name: Download flatpak repo
uses: actions/download-artifact@v3
with:
name: ${{ env.FLATPAK_BUILD_REPO }}
- name: Create OCI bundle
run: |
set -e
mkdir -p ${FLATPAK_BUILD_REPO}/{extensions,refs/{mirrors,remotes},state,tmp/cache}
flatpak build-bundle \
--oci \
--runtime-repo=https://flathub.org/repo/flathub.flatpakrepo \
${FLATPAK_BUILD_REPO} ${FLATPAK_BUNDLE} ${APP_ID} ${FLATPAK_BRANCH}
- name: Publish OCI image
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
REGISTRY_AUTH_FILE: /tmp/auth.json
run: |
export IMAGE_REPOSITORY=$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')
set -e
skopeo login --username "${{ github.actor }}" --password-stdin ghcr.io <<<$GITHUB_TOKEN
skopeo copy \
oci:${FLATPAK_BUNDLE} \
docker://ghcr.io/${IMAGE_REPOSITORY}:$IMAGE_TAG
- name: Update static index
env:
REGISTRY_AUTH_FILE: /tmp/auth.json
run: |
export IMAGE_REPOSITORY=$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')
set -e
git clone -b gh-pages https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git gh-pages
skopeo inspect docker://ghcr.io/${IMAGE_REPOSITORY}:$IMAGE_TAG | \
jq '. as $img | { "Registry": "https://ghcr.io/", "Results": [ { "Name": "'${IMAGE_REPOSITORY}'", "Images": [$img] } ] }' \
> gh-pages/index/static
cd gh-pages
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add index/static
git commit -m "Update index for ${GITHUB_SHA:0:7}"
git push