From 6c7bc0eff83d94b9fa02f1b0764b7d42b97aeee9 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 30 Oct 2023 03:39:39 +0100 Subject: [PATCH] Try using a custom container --- .github/workflows/container.yml | 39 +++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 12 ++-------- Containerfile | 10 +++++++++ scripts/deps.sh | 4 ---- scripts/test.sh | 9 +------- scripts/update.sh | 9 +------- scripts/user.sh | 3 --- 7 files changed, 53 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/container.yml create mode 100644 Containerfile delete mode 100644 scripts/deps.sh delete mode 100644 scripts/user.sh diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml new file mode 100644 index 0000000..62e9083 --- /dev/null +++ b/.github/workflows/container.yml @@ -0,0 +1,39 @@ +--- +name: Container +on: + push: + branches: + - main + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + container: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + - uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v4 + id: meta + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7ae1023..6efb659 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,13 +14,9 @@ jobs: test: runs-on: ubuntu-latest container: - image: archlinux:latest + image: ghcr.io/inko-lang/aur:latest steps: - uses: actions/checkout@v4 - - name: Installing dependencies - run: bash scripts/deps.sh - - name: Creating build user - run: bash scripts/user.sh - name: Running tests run: bash scripts/test.sh "${{ github.event.inputs.name }}" release: @@ -28,15 +24,11 @@ jobs: - test runs-on: ubuntu-latest container: - image: archlinux:latest + image: ghcr.io/inko-lang/aur:latest permissions: contents: write steps: - uses: actions/checkout@v4 - - name: Installing dependencies - run: bash scripts/deps.sh - - name: Creating build user - run: bash scripts/user.sh - name: Updating PKGBUILD run: | bash scripts/update.sh inko "${{ github.event.inputs.version }}" diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..9c47df6 --- /dev/null +++ b/Containerfile @@ -0,0 +1,10 @@ +FROM archlinux:latest + +RUN pacman -Syu --noconfirm --noprogress pacman-contrib base-devel bash git \ + sudo openssh + +RUN useradd --no-create-home build \ + && echo 'build ALL=(ALL:ALL) ALL' > /etc/sudoers.d/build + +USER build +CMD ["/usr/bin/bash"] diff --git a/scripts/deps.sh b/scripts/deps.sh deleted file mode 100644 index 86d84f1..0000000 --- a/scripts/deps.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -pacman -Syu --noconfirm --noprogress pacman-contrib base-devel bash git sudo \ - openssh diff --git a/scripts/test.sh b/scripts/test.sh index 5c2c49c..53bb19a 100644 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -11,13 +11,6 @@ then fi cd "${name}" - -if [[ -v CI ]] -then - sudo -u build makepkg --cleanbuild --force --noconfirm --clean -else - makepkg --cleanbuild --force --noconfirm --clean -fi - +makepkg --cleanbuild --force --noconfirm --clean rm *.tar.gz rm *.zst diff --git a/scripts/update.sh b/scripts/update.sh index cd41170..2f89e7a 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -23,14 +23,7 @@ sed --regexp-extended --in-place --expression \ "s/pkgver=(.+)/pkgver=${version}/g" PKGBUILD updpkgsums PKGBUILD - -if [[ -v CI ]] -then - sudo -u build makepkg --printsrcinfo | tee .SRCINFO -else - makepkg --printsrcinfo > .SRCINFO -fi - +makepkg --printsrcinfo > .SRCINFO rm *.tar.gz git add PKGBUILD .SRCINFO diff --git a/scripts/user.sh b/scripts/user.sh deleted file mode 100644 index 5282d3b..0000000 --- a/scripts/user.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -useradd -d /build -m build