Skip to content

Commit b82266b

Browse files
authored
refactor: improve repo structure (#11)
1 parent 23c5b2a commit b82266b

File tree

13 files changed

+75
-48
lines changed

13 files changed

+75
-48
lines changed

.github/workflows/branches.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: check-branches
2-
32
on:
43
- pull_request
54

@@ -8,8 +7,15 @@ jobs:
87
name: Shellcheck
98
runs-on: ubuntu-20.04
109
steps:
11-
- uses: actions/checkout@v2
12-
- name: Run ShellCheck
10+
- name: Checkout the repo
11+
uses: actions/checkout@v2
12+
- name: Lint Bash scripts
1313
uses: ludeeus/action-shellcheck@master
14+
env:
15+
SHELLCHECK_OPTS: -x
16+
with:
17+
scandir: "./scripts"
18+
- name: Lint Dockerfile
19+
uses: brpaz/hadolint-action@v1.2.1
1420
with:
15-
scandir: "./ci"
21+
dockerfile: Dockerfile

.github/workflows/build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ jobs:
2020
- name: Checkout the repo
2121
uses: actions/checkout@v2
2222
- name: Check last version
23-
run: bash ./ci/check-last-version.bash
23+
run: bash ./scripts/check-last-version.bash
2424
- name: Import environment variables
2525
shell: bash
2626
run: |
2727
while read line; do
2828
echo "$line" >> $GITHUB_ENV
29-
done < .env
29+
done < assets/variables
3030
- name: Set env vars
3131
id: var
32-
run: . ./ci/set-env-vars.bash
32+
run: . ./scripts/set-env-vars.bash
3333
outputs:
3434
pkg_version: ${{ steps.var.outputs.pkg_version }}
3535

@@ -49,11 +49,11 @@ jobs:
4949
run: |
5050
while read line; do
5151
echo "$line" >> $GITHUB_ENV
52-
done < .env
52+
done < assets/variables
5353
- name: Patch glibc
54-
run: bash ./ci/patch-glibc.bash
54+
run: bash ./scripts/patch-glibc.bash
5555
- name: Build artifacts
56-
run: bash ./ci/build-artifacts.bash
56+
run: bash ./scripts/build-artifacts.bash
5757
- name: Create release
5858
id: create_release
5959
uses: actions/create-release@v1
@@ -79,4 +79,4 @@ jobs:
7979
env:
8080
PRIV_KEY: ${{ secrets.PRIV_KEY }}
8181
PUB_KEY: ${{ secrets.PUB_KEY }}
82-
run: bash ./ci/push-to-aur.bash
82+
run: bash ./scripts/push-to-aur.bash

.github/workflows/manual.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ jobs:
2020
- name: Checkout the repo
2121
uses: actions/checkout@v2
2222
- name: Check last version
23-
run: bash ./ci/check-last-version.bash
23+
run: bash ./scripts/check-last-version.bash
2424
- name: Import environment variables
2525
shell: bash
2626
run: |
2727
while read line; do
2828
echo "$line" >> $GITHUB_ENV
29-
done < .env
29+
done < assets/variables
3030
- name: Set env vars
3131
id: var
32-
run: . ./ci/set-env-vars.bash
32+
run: . ./scripts/set-env-vars.bash
3333
outputs:
3434
pkg_version: ${{ steps.var.outputs.pkg_version }}
3535

@@ -49,11 +49,11 @@ jobs:
4949
run: |
5050
while read line; do
5151
echo "$line" >> $GITHUB_ENV
52-
done < .env
52+
done < assets/variables
5353
- name: Patch glibc
54-
run: bash ./ci/patch-glibc.bash
54+
run: bash ./scripts/patch-glibc.bash
5555
- name: Build artifacts
56-
run: bash ./ci/build-artifacts.bash
56+
run: bash ./scripts/build-artifacts.bash
5757
- name: Upload artifacts
5858
uses: actions/upload-artifact@v2
5959
with:

Dockerfile

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
#
1515
FROM archlinux:base-devel
1616

17-
COPY deps .
18-
COPY .env .
17+
ARG UPSTREAM_BRANCH
18+
ARG UPSTREAM_REPO
19+
ARG USR
20+
ARG USR_HOME
1921

2022
ENV CC="/usr/bin/clang" \
2123
CXX="/usr/bin/clang++" \
@@ -26,10 +28,12 @@ ENV CC="/usr/bin/clang" \
2628
CFLAGS="-g -flto -fuse-ld=lld" \
2729
CXXFLAGS="-g -flto -fuse-ld=lld"
2830

29-
RUN /bin/bash -c "source .env"
31+
COPY assets/ /assets/
32+
COPY scripts/ /scripts/
3033

31-
RUN pacman -Syu --noconfirm && \
32-
pacman -U --noconfirm libgccjit-10.2.0-2-x86_64.pkg.tar.zst && \
34+
RUN \
35+
pacman -Syu --noconfirm && \
36+
pacman -U --noconfirm /assets/libgccjit-10.2.0-2-x86_64.pkg.tar.zst && \
3337
pacman -S --noconfirm \
3438
# Emacs deps
3539
alsa-lib \
@@ -52,21 +56,24 @@ RUN pacman -Syu --noconfirm && \
5256
expac \
5357
git \
5458
jq \
55-
openssh && \
56-
groupadd -r pcr && useradd --no-log-init -r -g pcr pcr && \
57-
mkdir "$HOME" && \
58-
chown -R pcr:pcr "$HOME" && \
59-
echo "pcr ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/user && \
59+
openssh
60+
61+
RUN \
62+
groupadd -r "$USR" && useradd --no-log-init -r -g "$USR" "$USR" && \
63+
mkdir "$USR_HOME" && \
64+
chown -R "$USR":"$USR" "$USR_HOME" && \
65+
echo "$USR ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/user && \
6066
chmod 0440 /etc/sudoers.d/user
6167

62-
WORKDIR $HOME
68+
WORKDIR $USR_HOME
6369

64-
COPY PKGBUILD .
65-
COPY pull.bash .
70+
USER $USR
6671

67-
RUN chown -R pcr:pcr "$HOME"
68-
USER pcr
72+
SHELL ["/bin/bash", "-c"]
6973

70-
RUN ["./pull.bash"]
71-
RUN makepkg && \
74+
RUN \
75+
cp /scripts/pull.bash . && \
76+
cp /assets/PKGBUILD . && \
77+
./pull.bash && \
78+
makepkg && \
7279
rm emacs-1-1-x86_64.pkg.tar.zst

PKGBUILD renamed to assets/PKGBUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ source=()
1010
sha1sums=()
1111

1212
build() {
13-
cd "$HOME"/emacs
13+
cd "$USR_HOME"/emacs
1414

1515
[[ -x configure ]] || ( ./autogen.sh git && ./autogen.sh autoconf )
1616

@@ -42,7 +42,7 @@ build() {
4242
}
4343

4444
package() {
45-
cd "$HOME"/emacs
45+
cd "$USR_HOME"/emacs
4646

4747
make DESTDIR="$pkgdir" install
4848

.env renamed to assets/variables

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
AUR_DNS=aur.archlinux.org
22
AUR_IP=95.216.144.15
33
AUR_PKG=emacs-gcc-wayland-devel-bin
4-
HOME=/home/pcr
4+
USR=pcr
5+
USR_HOME=/home/pcr
56
PKG_REL=1
67
UPSTREAM_API=https://api.github.com/repos/flatwhatson/emacs
78
UPSTREAM_BRANCH=pgtk-nativecomp
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
set -euxo pipefail
44

5-
cd "$HOME"
5+
cd "$USR_HOME"
66

77
# Get sources
8-
cp "$GITHUB_WORKSPACE"/pull.bash pull.bash
9-
cp "$GITHUB_WORKSPACE"/PKGBUILD PKGBUILD
8+
cp "$GITHUB_WORKSPACE"/scripts/pull.bash pull.bash
9+
cp "$GITHUB_WORKSPACE"/assets/PKGBUILD PKGBUILD
1010
./pull.bash
11-
chown -R pcr:pcr emacs
11+
chown -R "$USR":"$USR" emacs
1212

1313
# Create artifacts
14-
su pcr -c "makepkg"
14+
su "$USR" -c "makepkg"
1515

1616
# Unpack artifacts
1717
mkdir out

scripts/docker-build.bash

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
# shellcheck source=assets/variables
4+
source assets/variables
5+
6+
DOCKER_BUILDKIT=1 docker build \
7+
--build-arg UPSTREAM_BRANCH="$UPSTREAM_BRANCH" \
8+
--build-arg UPSTREAM_REPO="$UPSTREAM_REPO" \
9+
--build-arg USR="$USR" \
10+
--build-arg USR_HOME="$USR_HOME" \
11+
.

0 commit comments

Comments
 (0)