-
Notifications
You must be signed in to change notification settings - Fork 30
165 lines (138 loc) · 5.25 KB
/
appimage.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
162
163
164
165
on:
push:
pull_request:
workflow_dispatch:
name: CI-DOCKER
env:
GTK_VERSION: 4.14.4
IMAGE_NAME: ${{ github.repository }}-gtk-4.14.4
IMAGE_TAG: ${{ github.ref_name }}
jobs:
create-docker-image:
permissions:
contents: read
packages: write
attestations: write
id-token: write
name: Create Docker image
runs-on: ubuntu-latest
outputs:
NAME: ${{ env.IMAGE_NAME }}
TAG: ${{ env.IMAGE_TAG }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Escape image tag
run: |
echo "IMAGE_TAG=$(echo ${{ env.IMAGE_TAG }} | sed -e 's/\//-/g')" >> $GITHUB_ENV
echo "IMAGE_NAME: ${{ env.IMAGE_NAME }}"
echo "IMAGE_TAG: ${{ env.IMAGE_TAG }}"
- name: Check if Dockerfile has changed
uses: dorny/paths-filter@v3
id: changed
with:
base: ${{ github.ref_name }}
filters: |
dockerfile:
- "appimage/docker/**"
- name: Check if Docker image exists
id: exists
shell: bash
run: |
declare -a HEADERS=(
'-H' "Accept: application/vnd.oci.image.manifest.v1+json"
'-H' "Accept: application/vnd.oci.image.index.v1+json"
'-H' "Authorization: Bearer $(echo ${{ secrets.GITHUB_TOKEN }} | base64)"
)
RESULT=$(curl "${HEADERS[@]}" https://ghcr.io/v2/${IMAGE_NAME}/manifests/${IMAGE_TAG})
echo 'dockerimage<<EOF' >> $GITHUB_OUTPUT
echo ${RESULT} | jq 'has("manifests")' >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo
echo exists: ${{ steps.changed.outputs.dockerfile }}
- name: Log in to the Container registry
if: ${{ steps.changed.outputs.dockerfile == 'true' || steps.exists.outputs.dockerimage == 'false' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
if: ${{ steps.changed.outputs.dockerfile == 'true' || steps.exists.outputs.dockerimage == 'false' }}
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
if: ${{ steps.changed.outputs.dockerfile == 'true' || steps.exists.outputs.dockerimage == 'false' }}
id: push
uses: docker/build-push-action@v6
with:
context: appimage/docker/
push: true
tags: ghcr.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
cache-from: type=gha, scope=${{ env.IMAGE_TAG }}
cache-to: type=gha, scope=${{ env.IMAGE_TAG }}, mode=max
- name: Generate artifact attestation
if: ${{ steps.changed.outputs.dockerfile == 'true' || steps.exists.outputs.dockerimage == 'false' }}
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
build-linux-appimage:
permissions:
contents: read
packages: read
needs: create-docker-image
name: Build Linux AppImage
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ needs.create-docker-image.outputs.NAME }}:${{ needs.create-docker-image.outputs.TAG }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Workaround issues when GitHub does not respect the HOME env var
run: |
# GitHub Actions only supports containers running as root
# see: https://github.com/actions/checkout/issues/1014
mv /home/runner/.cargo $HOME
mv /home/runner/.nvm $HOME
mv /home/runner/.rustup $HOME
- uses: Swatinem/rust-cache@v2
- name: Install toolchain
run: |
rustup toolchain install stable
rustup default stable
- name: Build packetry binary
run: |
cargo build --release
- name: Test under XVFB (Linux)
run: |
xvfb-run cargo test
if: runner.os == 'Linux'
- name: Install cargo-license (Linux)
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: cargo-license
- name: Gather licenses (Linux)
# If the default shell is used, one command failing does not fail the action.
shell: bash
run: |
pip install license-expression
python wix/rust_licenses.py > appimage/packetry.AppDir/usr/share/doc/LICENSE-static-libraries.txt
mv wix/full-licenses appimage/packetry.AppDir/usr/share/doc
cp LICENSE appimage/packetry.AppDir/usr/share/doc/LICENSE-packetry.txt
- name: Run build appimage action (Linux)
uses: ./appimage/
with:
executable: target/release/packetry
icon-file: appimage/dist/icon.png
desktop-file: appimage/dist/packetry.desktop
appdir: appimage/packetry.AppDir
- name: Upload AppImage binary (Linux)
uses: actions/upload-artifact@v4
with:
name: Linux AppImage binary
path: packetry-x86_64.AppImage
if-no-files-found: error