Skip to content

Commit f996ac5

Browse files
committed
v1
0 parents  commit f996ac5

File tree

15 files changed

+272
-0
lines changed

15 files changed

+272
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish Docker
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: linuxdeepin/deepin-github
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v2
22+
23+
- name: Log in to the Container registry
24+
uses: docker/login-action@v1
25+
with:
26+
registry: ${{ env.REGISTRY }}
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Extract metadata (tags, labels) for Docker
31+
id: meta
32+
uses: docker/metadata-action@v2
33+
with:
34+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
35+
36+
- name: Build and push Docker image
37+
uses: docker/build-push-action@v2
38+
with:
39+
context: .
40+
push: true
41+
tags: ${{ steps.meta.outputs.tags }}
42+
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Publish Pbuilder
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@master
13+
- name: Build Pbuilder
14+
run: mkpbuilder/scripts/build-pbuilder-tgz.sh
15+
- name: Upload release artifacts
16+
uses: softprops/action-gh-release@v1
17+
with:
18+
files: pbuilder.tgz

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM debian:sid-slim
2+
RUN apt update
3+
RUN apt install -y sudo pbuilder devscripts ca-certificates
4+
5+
COPY entrypoint.sh /entrypoint.sh
6+
ADD common /app/common
7+
ADD repos /app/repos
8+
9+
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Deepin Pbuilder Docker Image
2+
3+
[简体中文](./README_zh.md)
4+
5+
## What is this
6+
7+
This is a docker image for build Debian package.
8+
9+
[![Publish Docker](https://github.com/linuxdeepin/deepin-github/actions/workflows/release-docker.yml/badge.svg)](https://github.com/linuxdeepin/deepin-github/actions/workflows/release-docker.yml)
10+
[![Publish Pbuilder](https://github.com/linuxdeepin/deepin-github/actions/workflows/release-pbuilder.yml/badge.svg)](https://github.com/linuxdeepin/deepin-github/actions/workflows/release-pbuilder.yml)
11+
12+
## How to use this in Github Actions
13+
14+
create Github Action YAML file `.github/workflows/pr.yml`:
15+
16+
``` yaml
17+
on: [pull_request]
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
container:
23+
image: ghcr.io/linuxdeepin/deepin-github:latest
24+
options: --privileged
25+
steps:
26+
- uses: actions/checkout@v2
27+
- run: /entrypoint.sh
28+
```
29+
30+
Use deepin-community repository by default, we can use `/entrypoint.sh reponame` to special which repo used for compiling.
31+
32+
The currently maintainly repos could be found in [repos folder](./repos).
33+
34+
35+
Multi-repos build Actions example:
36+
37+
``` yaml
38+
on: [pull_request]
39+
40+
jobs:
41+
build:
42+
runs-on: ubuntu-latest
43+
container:
44+
image: ghcr.io/linuxdeepin/deepin-github:latest
45+
options: --privileged
46+
strategy:
47+
matrix:
48+
repo: [deepin, buster]
49+
steps:
50+
- uses: actions/checkout@v2
51+
- run: /entrypoint.sh ${{ matrix.repo }}
52+
```
53+
54+
55+
## Why this image required `privileged`
56+
57+
Because we use [Pbuilder](https://pbuilder-team.pages.debian.net/pbuilder) to build package, Pbuilder need permission to mount something like `/proc` ...

README_zh.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Deepin Pbuilder Docker 镜像
2+
3+
[English](README.md)
4+
5+
## 介绍
6+
7+
这是一个编译 Debian 包的 Docker 镜像
8+
9+
[![Publish Docker](https://github.com/linuxdeepin/deepin-github/actions/workflows/release-docker.yml/badge.svg)](https://github.com/linuxdeepin/deepin-github/actions/workflows/release-docker.yml)
10+
[![Publish Pbuilder](https://github.com/linuxdeepin/deepin-github/actions/workflows/release-pbuilder.yml/badge.svg)](https://github.com/linuxdeepin/deepin-github/actions/workflows/release-pbuilder.yml)
11+
12+
## 如何在Github Actions 里使用
13+
14+
编辑 `.github/workflows/pr.yml`:
15+
16+
``` yaml
17+
on: [pull_request]
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
container:
23+
image: ghcr.io/linuxdeepin/deepin-github:latest
24+
options: --privileged
25+
steps:
26+
- uses: actions/checkout@v2
27+
- run: /entrypoint.sh
28+
```
29+
30+
默认使用Deepin 社区仓库编译,可以通过`/entrypoint.sh 仓库名`来指定使用哪个仓库来编译, 当前支持的仓库可以在 [repos 文件夹](./repos) 中看到
31+
32+
33+
多仓库Actions 示例:
34+
35+
``` yaml
36+
on: [pull_request]
37+
38+
jobs:
39+
build:
40+
runs-on: ubuntu-latest
41+
container:
42+
image: ghcr.io/linuxdeepin/deepin-github:latest
43+
options: --privileged
44+
strategy:
45+
matrix:
46+
repo: [deepin, buster]
47+
steps:
48+
- uses: actions/checkout@v2
49+
- run: /entrypoint.sh ${{ matrix.repo }}
50+
```
51+
52+
53+
54+
55+
## 为什么这个镜像要求 `privileged` 权限
56+
57+
因为我们选择使用 [Pbuilder](https://pbuilder-team.pages.debian.net/pbuilder) 来编包, Pbuilder 需要一些权限来挂载 `/proc` 之类的目录
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Acquire::http::No-Cache true;
2+
Acquire::http::Pipeline-Depth 0;

common/scripts/build-package.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -x
3+
BUILD_DIR="/opt/cache/build"
4+
dpkg-source -b ./
5+
sudo /usr/sbin/pbuilder --update --no-targz --buildplace ${BUILD_DIR}
6+
sudo DEB_BUILD_OPTIONS=nocheck /usr/sbin/pbuilder --build --no-targz --buildplace ${BUILD_DIR} --buildresult /opt/cache/build-result ../*.dsc

common/scripts/change-version.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
set -x
3+
short_hash=$(git log -n 1 --pretty=format:'%h')
4+
tag=$(git describe --tags --long | awk -F "-$num-g$short_hash" '{print $1}') || echo
5+
if [ $tag ]; then
6+
version=${tag}+g${short_hash}
7+
else
8+
version=0.0.0+g${short_hash}
9+
fi
10+
11+
if [[ $(echo $(cat debian/changelog | head -n 1 | awk -F '(' '{print $2}' | awk -F ')' '{print $1}') | grep :) ]]; then
12+
prefix=$(cat debian/changelog | head -n 1 | awk -F '(' '{print $2}' | awk -F ')' '{print $1}' | awk -F ':' '{print $1}')
13+
fi
14+
15+
if [ ${prefix} ]; then
16+
version=${prefix}:${version}
17+
fi
18+
19+
if [ -f debian/source/format ] && [[ $(grep quilt debian/source/format) ]]; then
20+
dch -M -bv "${version}-1" -D unstable "hash: ${short_hash}"
21+
git deborig --force HEAD
22+
else
23+
dch -M -bv "${version}" -D unstable "hash: ${short_hash}"
24+
fi

common/scripts/prepare-pbuilder.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -x
3+
BUILD_DIR="/opt/cache/build"
4+
sudo mkdir -p ${BUILD_DIR}
5+
wget -q https://github.com/linuxdeepin/deepin-github/releases/latest/download/pbuilder.tgz -O /opt/cache/pbuilder.tgz
6+
sudo mkdir -p ${BUILD_DIR}
7+
sudo tar xf /opt/cache/pbuilder.tgz -C ${BUILD_DIR}
8+
sudo rm -rfv ${BUILD_DIR}/proc
9+
sudo cp /app/common/in_pbuilder/* ${BUILD_DIR}/ -rv
10+
sudo cp /app/repos/${repo}/in_pbuilder/* ${BUILD_DIR}/ -rv
11+
cat ${BUILD_DIR}/etc/apt/sources.list

entrypoint.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -x
3+
repos=$(ls -d /app/repos/* | awk -F '/' '{print $NF}')
4+
5+
for m_repo in $repos; do
6+
case "$m_repo" in
7+
$1)
8+
export repo=$1
9+
break
10+
;;
11+
*)
12+
export repo=deepin
13+
;;
14+
esac
15+
done
16+
/app/common/scripts/prepare-pbuilder.sh
17+
/app/common/scripts/change-version.sh
18+
/app/common/scripts/build-package.sh

0 commit comments

Comments
 (0)