Compare commits

..

31 Commits

Author SHA1 Message Date
Ahmad Husen 65444430c4 chore: release v1.1.0
CI / Test (with Dockerfile) (push) Successful in 1m21s
CI / Publish container image (push) Has been cancelled
CI / Test (with prebuilt Container Image) (push) Has been cancelled
CI / Release (push) Has been cancelled
2021-10-02 00:09:27 +07:00
Ahmad Husen b3890e00a5 Merge pull request #4 from datakrama/feature/pkgrel
feat: update pkgrel
2021-10-01 22:58:06 +07:00
Ahmad Husen 3487dc866b feat: update pkgrel 2021-10-01 22:54:16 +07:00
Ahmad Husen 581d4292cc Merge pull request #3 from datakrama/feature/pkgver
feat: update pkgver
2021-10-01 22:34:38 +07:00
Ahmad Husen 4d1983388b feat: update pkgver 2021-10-01 22:27:55 +07:00
Ahmad Husen fb6ab46b3f Merge pull request #2 from datakrama/bugfix/missing-bash-set-e
fix(bash): missing 'set e'
2021-10-01 20:41:08 +07:00
Ahmad Husen 796ddff1d3 chore: change branding color 2021-10-01 14:38:53 +07:00
Ahmad Husen 3d91dafd70 fix(bash): missing 'set e' 2021-10-01 13:58:10 +07:00
Ahmad Husen bc46e9c8d4 ci: update sample PKGBUILD 2021-09-30 17:07:53 +07:00
Ahmad Husen 3aa6342a73 feat(container): copy '.git' folder from WORKPATH
CI / Pretest (with Dockerfile) (push) Successful in 1m48s
CI / Test (with pre-built Container Image) (push) Has been cancelled
CI / Publish container image (push) Has been cancelled
2021-05-30 14:24:17 +07:00
Ahmad Husen 8987dba528 feat(container): always under 2021-05-30 14:20:58 +07:00
Ahmad Husen b8114f2ee3 feat(container): change value 2021-05-30 14:14:59 +07:00
Ahmad Husen 42c6bfae1e feat(container): create /tmp folder manually 2021-05-30 14:07:35 +07:00
Ahmad Husen fcedc2d02c feat(container): copy .git to /tmp folder 2021-05-30 14:05:13 +07:00
Ahmad Husen 7f32fc286b feat(container): only copy needed files 2021-05-30 14:00:48 +07:00
Ahmad Husen ec0ee87e6a feat(bash): run all commmand with non-root user 2021-05-30 13:52:20 +07:00
Ahmad Husen 3c654a34ce fix(container): unknown rsync option 2021-05-30 13:38:37 +07:00
Ahmad Husen 65e9437ece feat(container): use rsync instead cp 2021-05-30 13:36:39 +07:00
Ahmad Husen 0593cc597c fix(bash): cp permission 2021-05-30 13:26:06 +07:00
Ahmad Husen 88a8c57641 feat(bash): copying files to /tmp instead of chown 2021-05-30 13:19:29 +07:00
Ahmad Husen f7ff69715a fix(ci): conditional syntax & others
CI / Pretest (with Dockerfile) (push) Successful in 1m49s
CI / Publish container image (push) Has been cancelled
CI / Test (with pre-built Container Image) (push) Has been cancelled
2021-05-26 10:29:34 +07:00
Ahmad Husen 5fa9ff1a99 fix: path for action run 2021-05-26 10:26:23 +07:00
Ahmad Husen b259baf950 fix: syntax on action.yml 2021-05-26 10:21:34 +07:00
Ahmad Husen 77f0819445 ci: don't publish container image when PR pushed 2021-05-24 14:38:32 +07:00
Ahmad Husen 23631f017d fix(ci): wrong operator 2021-05-23 21:45:07 +07:00
Ahmad Husen 9106fe5df2 ci: combine 2 workflow to run asynchronously 2021-05-23 21:43:29 +07:00
Ahmad Husen e2ed7401c9 feat: set grouped output for entrypoint.sh 2021-05-23 20:48:35 +07:00
Ahmad Husen 64596b74e7 feat(docker): change setup user script on Dockerfile 2021-05-23 20:33:16 +07:00
Ahmad Husen b0781d01e1 feat: add missing docker action's metadata input 2021-05-22 18:25:49 +07:00
Ahmad Husen d318fec45e feat: change action to use pre-built container image 2021-05-19 22:28:19 +07:00
Ahmad Husen 93e14b2832 feat: add more examples workflow
CD / Publish container image (push) Failing after 6m54s
2021-05-19 20:24:47 +07:00
7 changed files with 331 additions and 93 deletions
+122 -5
View File
@@ -4,25 +4,34 @@ on:
push: push:
branches: branches:
- "main" - "main"
tags:
- 'v*.*.*'
pull_request: pull_request:
branches: branches:
- "main" - "main"
jobs: jobs:
build: pretest:
name: Build name: Test (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: Get sample PKGBUILD - name: Update action.yml to build locally
run: wget https://github.com/official-human/nonicons-font/raw/main/PKGBUILD run: |
sed -i 's/.*image\:.*/ image\: \"Dockerfile\"/' action.yml
cat action.yml
- name: Test actions - name: Get sample PKGBUILD
run: wget https://github.com/datakrama/plenti-bin/raw/f5ffaaee02a2119aa16f6b7a27e87e198e096b47/PKGBUILD
- name: Running test
uses: ./ uses: ./
with: with:
pkgver: '0.4.26'
pkgrel: 2
updpkgsums: true updpkgsums: true
srcinfo: true srcinfo: true
@@ -31,3 +40,111 @@ jobs:
ls -la ls -la
git diff PKGBUILD git diff PKGBUILD
git diff .SRCINFO 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 prebuilt 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/datakrama/plenti-bin/raw/f5ffaaee02a2119aa16f6b7a27e87e198e096b47/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 test
uses: ./
with:
pkgver: '0.4.26'
pkgrel: 2
updpkgsums: true
srcinfo: true
- name: Show diff
run: |
ls -la
git diff PKGBUILD
git diff .SRCINFO
release:
name: Release
runs-on: ubuntu-latest
needs: test
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get branch/tag names
id: branch-name
uses: tj-actions/branch-names@v5
with:
strip_tag_prefix: "v"
- name: Read changelog
id: changelog-reader
uses: mindsers/changelog-reader-action@v2
with:
version: ${{ steps.branch-name.outputs.tag }}
path: ./CHANGELOG.md
- name: Create/update release
uses: ncipollo/release-action@v1
with:
tag: v${{ steps.branch-name.outputs.tag }}
name: v${{ steps.branch-name.outputs.tag }}
body: ${{ steps.changelog-reader.outputs.changes }}
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
-51
View File
@@ -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 }}
+50
View File
@@ -0,0 +1,50 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [1.1.0] - 2021-10-02
### Added
- Update `pkgver` on PKGBUILD
- Update `pkgrel` on PKGBUILD
### Fixed
- Missing `set -e` on bash
## [1.0.3] - 2021-05-30
### Fixed
- $GITHUB_WORKSPACE permission in step after using this action
## [1.0.2] - 2021-05-26
### Fixed
- Docker runner syntax
- Path sntax
## [1.0.1] - 2021-05-19
### Fixed
- Missing documentation
## [1.0.0] - 2021-05-19
### Added
- Initial release
[Unreleased]: https://github.com/datakrama/archlinux-package-action/compare/v1.1.0...HEAD
[1.0.3]: https://github.com/datakrama/archlinux-package-action/compare/v1.0.2...v1.0.3
[1.0.2]: https://github.com/datakrama/archlinux-package-action/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/datakrama/archlinux-package-action/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/datakrama/archlinux-package-action/releases/tag/v1.0.0
+3 -1
View File
@@ -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
+87 -5
View File
@@ -5,29 +5,35 @@
This action allows running tools needed for creating Arch Linux (and AUR) package. This action allows running tools needed for creating Arch Linux (and AUR) package.
Here's what this action can do: Here's what this action can do:
- Update checksums on PKGBUILD file - Update `pkgver`, `pkgrel`, or checksums on PKGBUILD file
- Generate [.SRCINFO](https://wiki.archlinux.org/title/.SRCINFO) based on your PKGBUILD
- Validate PKGBUILD with [namcap](https://wiki.archlinux.org/title/namcap) - Validate PKGBUILD with [namcap](https://wiki.archlinux.org/title/namcap)
- Generate [.SRCINFO](https://wiki.archlinux.org/title/.SRCINFO) based on your PKGBUILD
- Run [makepkg](https://wiki.archlinux.org/title/Makepkg) with custom flags (rather than default) - Run [makepkg](https://wiki.archlinux.org/title/Makepkg) with custom flags (rather than default)
## 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 |
| `pkgver` | String | | `false` | Update `pkgver` on your PKGBUILD |
| `pkgrel` | Integer | | `false` | Update `pkgrel` on your PKGBUILD |
| `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
#### 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.
@@ -42,9 +48,85 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v2
- name: Validate package - name: Validate package
uses: datakrama/archlinux-package-action@v1 uses: datakrama/archlinux-package-action@v1
``` ```
#### 2. Only generate .SRCINFO
```yaml
name: CI
on:
push:
branches: main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Validate package
uses: datakrama/archlinux-package-action@v1
with:
flags: ''
namcap: false
srcinfo: true
```
#### 3. Only update checksums on PKGBUILD
```yaml
name: CI
on:
push:
branches: main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Validate package
uses: datakrama/archlinux-package-action@v1
with:
flags: ''
namcap: false
updpkgsums: true
```
#### 4. Custom path & custom flags
```yaml
name: CI
on:
push:
branches: main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Validate package
uses: datakrama/archlinux-package-action@v1
with:
path: package
flags: '-si --noconfirm'
namcap: false
```
## 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)
+25 -15
View File
@@ -1,38 +1,48 @@
# 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: 'blue'
inputs: inputs:
path: path:
description: "Location for this action to run" description: 'Location for this action to run'
default: "" default: ''
required: false
pkgver:
description: 'Update pkgver on PKGBUILD'
default: ''
required: false
pkgrel:
description: 'Update pkgrel on PKGBUILD'
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.pkgver }}
- ${{ inputs.pkgrel }}
- ${{ inputs.updpkgsums }} - ${{ inputs.updpkgsums }}
- ${{ inputs.srcinfo }} - ${{ inputs.srcinfo }}
- ${{ inputs.flags }} - ${{ inputs.flags }}
+44 -16
View File
@@ -1,37 +1,65 @@
#!/bin/sh -l #!/bin/bash
set -e
# 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 # Set path permision
sudo -u builder mkdir /tmp/gh-action
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 pkgver
if [[ -n $INPUT_PKGVER ]]; then
echo "::group::Updating pkgver on PKGBUILD"
sed -i "s:^pkgver=.*$:pkgver=$INPUT_PKGVER:g" PKGBUILD
git diff PKGBUILD
echo "::endgroup::"
fi fi
# Set path permision # Update pkgver
sudo chown -R builder $WORKPATH if [[ -n $INPUT_PKGREL ]]; then
cd $WORKPATH echo "::group::Updating pkgrel on PKGBUILD"
sed -i "s:^pkgrel=.*$:pkgrel=$INPUT_PKGREL:g" PKGBUILD
git diff PKGBUILD
echo "::endgroup::"
fi
# Update checksums # Update checksums
if [[ $INPUT_UPDPKGSUMS == true ]]; then if [[ $INPUT_UPDPKGSUMS == true ]]; then
echo "Update checksums on PKGBUILD" echo "::group::Updating checksums on PKGBUILD"
sudo -u builder updpkgsums sudo -u builder updpkgsums
git diff PKGBUILD git diff PKGBUILD
echo "::endgroup::"
fi fi
# Generate .SRCINFO # Generate .SRCINFO
if [[ $INPUT_SRCINFO == true ]]; then if [[ $INPUT_SRCINFO == true ]]; then
echo "Generate new .SRCINFO based on PKGBUILD" echo "::group::Generating new .SRCINFO based on PKGBUILD"
sudo -u builder makepkg --printsrcinfo > .SRCINFO sudo -u builder makepkg --printsrcinfo > .SRCINFO
git diff .SRCINFO git diff .SRCINFO
fi echo "::endgroup::"
# Run makepkg
if [[ -n "$INPUT_FLAGS" ]]; then
echo "Run makepkg with flags"
sudo -u builder makepkg $INPUT_FLAGS
fi fi
# Validate with namcap # Validate with namcap
if [[ $INPUT_NAMCAP == true ]]; then if [[ $INPUT_NAMCAP == true ]]; then
echo "Validate PKGBUILD with namcap" echo "::group::Validating PKGBUILD with namcap"
namcap -i PKGBUILD namcap -i PKGBUILD
echo "::endgroup::"
fi fi
# Run makepkg
if [[ -n $INPUT_FLAGS ]]; then
echo "::group::Running makepkg with flags"
sudo -u builder makepkg $INPUT_FLAGS
echo "::endgroup::"
fi
echo "::group::Copying files from /tmp/gh-action to $WORKPATH"
cp -fv /tmp/gh-action/PKGBUILD "$WORKPATH"/PKGBUILD
if [[ -e /tmp/gh-action/.SRCINFO ]]; then
cp -fv /tmp/gh-action/.SRCINFO "$WORKPATH"/.SRCINFO
fi
echo "::endgroup::"