Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3aa6342a73 | |||
| 8987dba528 | |||
| b8114f2ee3 | |||
| 42c6bfae1e | |||
| fcedc2d02c | |||
| 7f32fc286b | |||
| ec0ee87e6a | |||
| 3c654a34ce | |||
| 65e9437ece | |||
| 0593cc597c | |||
| 88a8c57641 | |||
| f7ff69715a | |||
| 5fa9ff1a99 | |||
| b259baf950 | |||
| 77f0819445 | |||
| 23631f017d | |||
| 9106fe5df2 | |||
| e2ed7401c9 | |||
| 64596b74e7 | |||
| b0781d01e1 | |||
| d318fec45e |
@@ -4,23 +4,104 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- "main"
|
- "main"
|
||||||
|
tags:
|
||||||
|
- 'v*.*.*'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- "main"
|
- "main"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
pretest:
|
||||||
name: Build
|
name: Pretest (with Dockerfile)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2.3.4
|
uses: actions/checkout@v2.3.4
|
||||||
|
|
||||||
|
- name: Update action.yml to build locally
|
||||||
|
run: |
|
||||||
|
sed -i 's/.*image\:.*/ image\: \"Dockerfile\"/' action.yml
|
||||||
|
cat action.yml
|
||||||
|
|
||||||
- name: Get sample PKGBUILD
|
- name: Get sample PKGBUILD
|
||||||
run: wget https://github.com/official-human/nonicons-font/raw/main/PKGBUILD
|
run: wget https://github.com/official-human/nonicons-font/raw/main/PKGBUILD
|
||||||
|
|
||||||
- name: Test actions
|
- name: Running tests
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
updpkgsums: true
|
||||||
|
srcinfo: true
|
||||||
|
|
||||||
|
- name: Show diff
|
||||||
|
run: |
|
||||||
|
ls -la
|
||||||
|
git diff PKGBUILD
|
||||||
|
git diff .SRCINFO
|
||||||
|
|
||||||
|
publish:
|
||||||
|
name: Publish container image
|
||||||
|
needs: pretest
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: OCI meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v3
|
||||||
|
with:
|
||||||
|
images: ghcr.io/${{ github.repository }}
|
||||||
|
tags: |
|
||||||
|
type=edge,branch=main
|
||||||
|
type=ref,event=branch
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=sha
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Login to GHCR
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Test (with pre-built Container Image)
|
||||||
|
needs: publish
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2.3.4
|
||||||
|
|
||||||
|
- name: Get sample PKGBUILD
|
||||||
|
run: wget https://github.com/official-human/nonicons-font/raw/main/PKGBUILD
|
||||||
|
|
||||||
|
- name: Update action.yml to use edge tagged container image
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
run: |
|
||||||
|
sed -i 's/.*image\:.*/ image\: \"docker\:\/\/ghcr.io\/${{ github.repository_owner }}\/${{ github.event.repository.name }}\:edge\"/' action.yml
|
||||||
|
cat action.yml
|
||||||
|
|
||||||
|
- name: Running tests
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
updpkgsums: true
|
updpkgsums: true
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
name: CD
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'main'
|
|
||||||
tags:
|
|
||||||
- 'v*.*.*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
container:
|
|
||||||
name: Publish container image
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: OCI meta
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v3
|
|
||||||
with:
|
|
||||||
images: ghcr.io/${{ github.repository }}
|
|
||||||
tags: |
|
|
||||||
type=edge,branch=main
|
|
||||||
type=ref,event=branch
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
type=semver,pattern={{major}}
|
|
||||||
type=sha
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v1
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
|
||||||
|
|
||||||
- name: Login to GHCR
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
+3
-1
@@ -5,7 +5,9 @@ FROM docker.io/library/archlinux:base-devel
|
|||||||
RUN pacman -Syu --needed --noconfirm pacman-contrib namcap git
|
RUN pacman -Syu --needed --noconfirm pacman-contrib namcap git
|
||||||
|
|
||||||
# Setup user
|
# Setup user
|
||||||
RUN useradd -m builder && \
|
RUN useradd --create-home --shell /bin/bash builder && \
|
||||||
|
passwd --delete builder && \
|
||||||
|
chown -vR builder:builder /home/builder && \
|
||||||
usermod -aG wheel builder && \
|
usermod -aG wheel builder && \
|
||||||
echo 'wheel ALL=(ALL:ALL) ALL' >> /etc/sudoers
|
echo 'wheel ALL=(ALL:ALL) ALL' >> /etc/sudoers
|
||||||
|
|
||||||
|
|||||||
@@ -13,20 +13,24 @@ Here's what this action can do:
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Requirement
|
### Requirement
|
||||||
|
|
||||||
- [PKGBUILD](https://wiki.archlinux.org/title/PKGBUILD) file inside your repository.
|
- [PKGBUILD](https://wiki.archlinux.org/title/PKGBUILD) file inside your repository.
|
||||||
|
- Use [actions/checkout](https://github.com/actions/checkout) in previous step. This is important, unless you want your [$GITHUB_WORKSPACE](https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables) folder to be empty.
|
||||||
|
|
||||||
### Customizing
|
### Customizing
|
||||||
|
|
||||||
Following inputs can be used as `step.with` keys
|
Following inputs can be used as `step.with` keys
|
||||||
|
|
||||||
| Name | Type | Default | Required | Description |
|
| Name | Type | Default | Required | Description |
|
||||||
|-------------------|-----------|-------------------------------|-----------|---------------------------------------|
|
|-------------------|-----------|-------------------------------|-----------|---------------------------------------|
|
||||||
| `path` | String | $GITHUB_WORKSPACE | `false` | Path where PKGBUILD is located |
|
| `path` | String | | `false` | Path where PKGBUILD is located. This path always located under $GITHUB_WORKSPACE |
|
||||||
| `updpkgsums` | Boolean | `false` | `false` | Update checksums on your PKGBUILD |
|
| `updpkgsums` | Boolean | `false` | `false` | Update checksums on your PKGBUILD |
|
||||||
| `srcinfo` | Boolean | `false` | `false` | Generate new .SRCINFO |
|
| `srcinfo` | Boolean | `false` | `false` | Generate new .SRCINFO |
|
||||||
| `namcap` | Boolean | `true` | `false` | Validate PKGBUILD |
|
| `namcap` | Boolean | `true` | `false` | Validate PKGBUILD |
|
||||||
| `flags` | String | `-cfs --noconfirm` | `false` | Flags after `makepkg` command. Leave this empty will disable this command. |
|
| `flags` | String | `-cfs --noconfirm` | `false` | Flags after `makepkg` command. Leave this empty will disable this command. |
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
#### 1. Basic
|
#### 1. Basic
|
||||||
|
|
||||||
This action will run `makepkg -cfs --noconfirm` command, then validate PKGBUILD with namcap.
|
This action will run `makepkg -cfs --noconfirm` command, then validate PKGBUILD with namcap.
|
||||||
@@ -51,7 +55,6 @@ jobs:
|
|||||||
|
|
||||||
#### 2. Only generate .SRCINFO
|
#### 2. Only generate .SRCINFO
|
||||||
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
@@ -76,7 +79,6 @@ jobs:
|
|||||||
|
|
||||||
#### 3. Only update checksums on PKGBUILD
|
#### 3. Only update checksums on PKGBUILD
|
||||||
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
@@ -101,7 +103,6 @@ jobs:
|
|||||||
|
|
||||||
#### 4. Custom path & custom flags
|
#### 4. Custom path & custom flags
|
||||||
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
@@ -125,4 +126,5 @@ jobs:
|
|||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
The scripts and documentation in this project are released under the [MIT License](./LICENSE)
|
The scripts and documentation in this project are released under the [MIT License](./LICENSE)
|
||||||
|
|||||||
+15
-15
@@ -1,36 +1,36 @@
|
|||||||
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
|
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
|
||||||
name: "Arch Linux's package action"
|
name: "Arch Linux's package action"
|
||||||
description: "GitHub Action to run Arch Linux's package tools"
|
description: "GitHub Action to run Arch Linux's package tools"
|
||||||
author: "datakrama"
|
author: 'datakrama'
|
||||||
branding:
|
branding:
|
||||||
icon: "package"
|
icon: 'package'
|
||||||
color: "green"
|
color: 'green'
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
path:
|
path:
|
||||||
description: "Location for this action to run"
|
description: 'Location for this action to run'
|
||||||
default: ""
|
default: ''
|
||||||
required: false
|
required: false
|
||||||
updpkgsums:
|
updpkgsums:
|
||||||
description: "Update checksums on PKGBUILD"
|
description: 'Update checksums on PKGBUILD'
|
||||||
default: "false"
|
default: 'false'
|
||||||
required: false
|
required: false
|
||||||
srcinfo:
|
srcinfo:
|
||||||
description: "Generate new .SRCINFO"
|
description: 'Generate new .SRCINFO'
|
||||||
default: "false"
|
default: 'false'
|
||||||
required: false
|
required: false
|
||||||
flags:
|
flags:
|
||||||
description: "Extra flags for makepkg"
|
description: 'Extra flags for makepkg'
|
||||||
default: "-cfs --noconfirm"
|
default: '-cfs --noconfirm'
|
||||||
required: false
|
required: false
|
||||||
namcap:
|
namcap:
|
||||||
description: "Validate package with namcap"
|
description: 'Validate package with namcap'
|
||||||
default: "true"
|
default: 'true'
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "docker"
|
using: 'docker'
|
||||||
image: "Dockerfile"
|
image: 'docker://ghcr.io/datakrama/archlinux-package-action:1'
|
||||||
args:
|
args:
|
||||||
- ${{ inputs.path }}
|
- ${{ inputs.path }}
|
||||||
- ${{ inputs.updpkgsums }}
|
- ${{ inputs.updpkgsums }}
|
||||||
|
|||||||
+26
-17
@@ -1,37 +1,46 @@
|
|||||||
#!/bin/sh -l
|
#!/bin/bash
|
||||||
|
|
||||||
# Set path
|
# Set path
|
||||||
WORKPATH=$GITHUB_WORKSPACE
|
echo '::group::Copying file from $WORKPATH to /tmp/gh-action'
|
||||||
if [[ -n "$INPUT_PATH" ]]; then
|
WORKPATH=$GITHUB_WORKSPACE/$INPUT_PATH
|
||||||
WORKPATH=$INPUT_PATH
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set path permision
|
# Set path permision
|
||||||
sudo chown -R builder $WORKPATH
|
sudo -u builder mkdir /tmp/gh-action
|
||||||
cd $WORKPATH
|
sudo -u builder cp -rfv $WORKPATH/.git /tmp/gh-action/.git
|
||||||
|
sudo -u builder cp -fv $WORKPATH/PKGBUILD /tmp/gh-action/PKGBUILD
|
||||||
|
cd /tmp/gh-action
|
||||||
|
echo '::endgroup::'
|
||||||
|
|
||||||
# Update checksums
|
# Update checksums
|
||||||
|
echo '::group::Updating checksums on PKGBUILD'
|
||||||
if [[ $INPUT_UPDPKGSUMS == true ]]; then
|
if [[ $INPUT_UPDPKGSUMS == true ]]; then
|
||||||
echo "Update checksums on PKGBUILD"
|
|
||||||
sudo -u builder updpkgsums
|
sudo -u builder updpkgsums
|
||||||
git diff PKGBUILD
|
git diff PKGBUILD
|
||||||
fi
|
fi
|
||||||
|
echo '::endgroup::'
|
||||||
|
|
||||||
# Generate .SRCINFO
|
# Generate .SRCINFO
|
||||||
|
echo '::group::Generating new .SRCINFO based on PKGBUILD'
|
||||||
if [[ $INPUT_SRCINFO == true ]]; then
|
if [[ $INPUT_SRCINFO == true ]]; then
|
||||||
echo "Generate new .SRCINFO based on PKGBUILD"
|
|
||||||
sudo -u builder makepkg --printsrcinfo > .SRCINFO
|
sudo -u builder makepkg --printsrcinfo > .SRCINFO
|
||||||
git diff .SRCINFO
|
git diff .SRCINFO
|
||||||
fi
|
fi
|
||||||
|
echo '::endgroup::'
|
||||||
# Run makepkg
|
|
||||||
if [[ -n "$INPUT_FLAGS" ]]; then
|
|
||||||
echo "Run makepkg with flags"
|
|
||||||
sudo -u builder makepkg $INPUT_FLAGS
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Validate with namcap
|
# Validate with namcap
|
||||||
|
echo '::group::Validating PKGBUILD with namcap'
|
||||||
if [[ $INPUT_NAMCAP == true ]]; then
|
if [[ $INPUT_NAMCAP == true ]]; then
|
||||||
echo "Validate PKGBUILD with namcap"
|
|
||||||
namcap -i PKGBUILD
|
namcap -i PKGBUILD
|
||||||
fi
|
fi
|
||||||
|
echo '::endgroup::'
|
||||||
|
|
||||||
|
# Run makepkg
|
||||||
|
echo '::group::Running makepkg with flags'
|
||||||
|
if [[ -n "$INPUT_FLAGS" ]]; then
|
||||||
|
sudo -u builder makepkg $INPUT_FLAGS
|
||||||
|
fi
|
||||||
|
echo '::endgroup::'
|
||||||
|
|
||||||
|
echo '::group::Copying files from /tmp/gh-action to $WORKPATH'
|
||||||
|
cp -fv /tmp/gh-action/PKGBUILD $WORKPATH/PKGBUILD
|
||||||
|
cp -fv /tmp/gh-action/.SRCINFO $WORKPATH/.SRCINFO
|
||||||
|
echo '::endgroup::'
|
||||||
|
|||||||
Reference in New Issue
Block a user