-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (131 loc) · 4.93 KB
/
Copy pathrelease.yml
File metadata and controls
156 lines (131 loc) · 4.93 KB
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
name: CI/CD
on:
push:
branches:
- master
permissions:
contents: write
pages: write
id-token: write
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
defaults:
run:
# GitHub Actions run without a TTY device. This is a workaround to get one,
# based on https://github.com/actions/runner/issues/241#issuecomment-2019042651
shell: 'script --return --quiet --log-out /dev/null --command "bash -e {0}"'
jobs:
build:
runs-on: ubuntu-latest
outputs:
keyring: ${{ steps.create-apt-repo.outputs.keyring }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Tune dpkg
uses: abbbi/github-actions-tune@v1
- name: Set dpkg
run: sudo rm -f /usr/local/bin/dpkg
- name: Tune apt
uses: firebuild/apt-eatmydata-action@v1
- name: Build package
id: build
run: |
sed -i "s,^Description:,Files:$(find . -type f | grep -oP '(?<=^\./).*' | grep -vP '^(\.|debian/)' | while read -r file; do echo -e " $file /opt/closure/$file"; done | grep -oP '.*(?=/)' | awk -v ORS='\\n' '1')Description:," debian/control
sed -i "s,^Files:,Files:$(find . -type f | grep -oP '(?<=^\./).*' | grep -oP '(?<=^debian/).+' | while read -r file; do echo -e " debian/$file /opt/closure/DEBIAN/$file"; done | grep -oP '.*(?=/)' | awk -v ORS='\\n' '1')," debian/control
sudo apt-get update
sudo apt-get install -y equivs
equivs-build debian/control
echo -e "built=$?\ntag=$(grep -oP '(?<=^Version: ).*' debian/control)\nmessage=$(git log -1 --pretty=%B)\n" >> "$GITHUB_OUTPUT"
- name: Create release
if: ${{ steps.build.outputs.built == '0' }}
uses: ncipollo/release-action@v1
with:
artifacts: "*.deb"
body: ${{ steps.build.outputs.message }}
tag: "v${{ steps.build.outputs.tag }}"
commit: "master"
allowUpdates: true
- name: Generate repo
uses: morph027/apt-repo-action@main
id: create-apt-repo
with:
import-from-repo-url: deb https://ipitio.github.io/closure master main
import-from-repo-failure-allow: true
repo-name: closure
codename: master
origin: github.com/ipitio/closure
signing-key: ${{ secrets.SIGNING_KEY }}
architectures: amd64 i386 arm64 armhf arm
- name: Copy script
run: |
echo "#!/bin/bash
sudonot() {
if command -v sudo >/dev/null; then
sudo -E \"\${@:-:}\" || \"\${@:-:}\"
else
\"\${@:-:}\"
fi
}
export DEBIAN_FRONTEND=noninteractive
sudonot apt-get update
sudonot apt-get -o APT::Get::AllowUnauthenticated=true install -qq gpg wget
sudonot mkdir -m 0755 -p /etc/apt/keyrings/
wget -qO- https://ipitio.github.io/closure/gpg.key | gpg --dearmor | sudonot tee /etc/apt/keyrings/closure.gpg > /dev/null
echo \"deb [signed-by=/etc/apt/keyrings/closure.gpg] https://ipitio.github.io/closure master main\" | sudonot tee /etc/apt/sources.list.d/closure.list &>/dev/null
sudonot chmod 644 /etc/apt/keyrings/closure.gpg
sudonot chmod 644 /etc/apt/sources.list.d/closure.list
sudonot apt-get update
sudonot apt-get -o APT::Get::AllowUnauthenticated=true install --no-install-recommends -qq closure
DEBIAN_FRONTEND=
" | tee ${{ steps.create-apt-repo.outputs.dir }}/i
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
id: upload-artifact
with:
name: github-pages
path: ${{ steps.create-apt-repo.outputs.dir }}
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy repo
id: deployment
uses: actions/deploy-pages@v4
test:
runs-on: ubuntu-latest
needs: deploy
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v5.3.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}