Skip to content

Commit c5f4790

Browse files
committed
Update the action
1 parent 1fb4cb7 commit c5f4790

File tree

12 files changed

+328
-29
lines changed

12 files changed

+328
-29
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ trim_trailing_whitespace = true
1010

1111
[*.php]
1212
indent_size = 4
13+
14+
[Makefile]
15+
indent_style = tab

.github/workflows/docker-build.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Docker build
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
docker-build:
8+
name: Build image
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Login to registry
17+
uses: docker/login-action@v3
18+
with:
19+
registry: ghcr.io
20+
username: ${{ github.actor }}
21+
password: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v3
25+
26+
- name: Set up Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Build
30+
uses: docker/build-push-action@v6
31+
with:
32+
context: .
33+
platforms: linux/amd64,linux/arm64
34+
push: false
35+
tags: ghcr.io/${{ github.repository }}:dev-${{ github.sha }}

.github/workflows/docker-push.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Docker push
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
- 'release/*'
9+
tags:
10+
- '*.*.*'
11+
12+
jobs:
13+
docker-push:
14+
name: Build and push image
15+
runs-on: ubuntu-latest
16+
17+
permissions:
18+
contents: read
19+
packages: write
20+
attestations: write
21+
id-token: write
22+
23+
steps:
24+
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Login to registry
29+
uses: docker/login-action@v3
30+
with:
31+
registry: ghcr.io
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Set up QEMU
36+
uses: docker/setup-qemu-action@v3
37+
38+
- name: Set up Buildx
39+
uses: docker/setup-buildx-action@v3
40+
41+
- name: Get metadata
42+
id: meta
43+
run: |
44+
echo "version=$(basename "$GITHUB_REF")" >> $GITHUB_OUTPUT
45+
46+
- name: Build and push
47+
uses: docker/build-push-action@v6
48+
with:
49+
context: .
50+
platforms: linux/amd64,linux/arm64
51+
push: true
52+
tags: ghcr.io/${{ github.repository }}:${{ steps.meta.outputs.version }}

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
8+
jobs:
9+
release:
10+
name: Create release
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
contents: write
15+
16+
steps:
17+
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Get metadata
22+
id: meta
23+
run: |
24+
echo "version=$(basename "$GITHUB_REF")" >> $GITHUB_OUTPUT
25+
26+
- name: Changelog
27+
id: changelog
28+
run: |
29+
echo "contents<<CHANGELOGEOF" >> $GITHUB_OUTPUT
30+
sed -e "1,/##/d" -e '/##/,$d' CHANGELOG.md >> $GITHUB_OUTPUT
31+
echo "CHANGELOGEOF" >> $GITHUB_OUTPUT
32+
33+
- name: Create release
34+
id: create_release
35+
uses: shogo82148/actions-create-release@v1
36+
with:
37+
body: ${{ steps.changelog.outputs.contents }}
38+
prerelease: ${{ contains(steps.meta.outputs.version, '-') }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.*
22
!.editorconfig
33
!.gitignore
4+
!.github
45
/build/
56
/dist/
67
/vendor/

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Changelog
2+
3+
## 0.3.0
4+
5+
* Push built image to the registry, so that it doesn't need to be built during the action run.
6+
* Updates the images PHP runtime to 8.4.
7+
8+
## 0.2.0
9+
10+
* Drop use of deprecated `set-ouput` command. For more information, see https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/.
11+
12+
## 0.1.6
13+
14+
* Takes plugin version number from `GITHUB_REF`. The resulting plugin version will be resolved from the tag or
15+
branch name that triggered the run, allowing so that it does not need to be kept up-to-date in `manifest.json`.
16+
* Update [mtxpc](https://github.com/gocom/MassPlugCompiler) to version 0.8.0.
17+
18+
## 0.1.5
19+
20+
* Update [mtxpc](https://github.com/gocom/MassPlugCompiler) to version 0.7.0.
21+
22+
## 0.1.4
23+
24+
* Update [mtxpc](https://github.com/gocom/MassPlugCompiler) to version 0.6.0.
25+
26+
## 0.1.3
27+
28+
* Migrate to the newer [mtxpc](https://github.com/gocom/MassPlugCompiler) plugin compiler version 0.4.0.
29+
30+
## 0.1.2
31+
32+
* No code changes, corrected README.md.
33+
34+
## 0.1.1
35+
36+
* Correct `compressed` and `uncompressed` output's paths.
37+
38+
## 0.1.0
39+
40+
* Initial release.

CONTRIBUTING.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Contributing
2+
=====
3+
4+
License
5+
-----
6+
7+
See [LICENSE](./LICENSE).
8+
9+
Versioning
10+
-----
11+
12+
[Semantic Versioning](https://semver.org/).
13+
14+
Local development environment
15+
-----
16+
17+
### Requirements
18+
19+
The local environment required:
20+
21+
* Docker
22+
* GNU Make
23+
24+
### Available commands
25+
26+
To list available commands, run:
27+
28+
```shell
29+
$ make help
30+
```
31+
32+
Building
33+
-----
34+
35+
The image is built and published automatically by CI. The CI builds automatically all git tags that follow
36+
Semantic Versioning naming convention, and branches `main`, `master`, and those that match `release/*`. The image tag
37+
is named after the tag's name, or the branch's last path component. For instance for branch `release/1.0`, the
38+
image tag would be named as `1.0`.
39+
40+
### Building locally
41+
42+
To manually build the Docker image on your local system, run:
43+
44+
```shell
45+
$ make build
46+
```
47+
48+
Smoke testing
49+
-----
50+
51+
The image can be manually tested on local before commiting changes with surface level smoke test. First, build
52+
the image, and then run the test:
53+
54+
```shell
55+
$ make build
56+
$ make test
57+
```
58+
59+
The test would clone example plugin repository to `.plugin`, and use the Docker image to build it. The build
60+
results would be written to `.plugin/build/package` directory. `GITHUB_OUTPUT` is written to `.plugin/output.txt`
61+
file.

Dockerfile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
1-
FROM composer:2.4.3 AS composer
1+
FROM composer:2.8.11 AS composer
22

3-
FROM php:8.1-cli
3+
FROM php:8.4-cli as build
44

55
COPY --from=composer /usr/bin/composer /usr/bin/composer
66

77
RUN apt-get update && apt-get install -y \
8-
bash \
98
git \
109
unzip \
1110
zlib1g-dev \
1211
libzip-dev
1312

1413
RUN docker-php-ext-install zip
15-
1614
RUN mkdir -p /composer && mkdir -p /compiler
1715

1816
ENV COMPOSER_HOME /composer
19-
2017
ENV COMPOSER_ALLOW_SUPERUSER 1
2118

2219
ADD composer.json /compiler/composer.json
23-
2420
ADD composer.lock /compiler/composer.lock
2521

26-
ADD compile.php /compiler/compile.php
27-
2822
RUN cd /compiler \
29-
&& composer install \
30-
&& cd -
23+
&& composer install --optimize-autoloader --no-dev
3124

32-
ADD entrypoint.sh /entrypoint.sh
25+
FROM php:8.4-cli
3326

27+
COPY --from=build /compiler/ /compiler/
28+
ADD compile.php /compiler/compile.php
29+
ADD entrypoint.sh /entrypoint.sh
3430
RUN chmod +x /entrypoint.sh
3531

3632
ENTRYPOINT ["/entrypoint.sh"]

Makefile

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
.PHONY: all build depends help push run shell test
2+
3+
DOCKER_IMAGE_NAME ?= ghcr.io/gocom/action-textpattern-package-plugin
4+
DOCKER_IMAGE_TAG ?= dev
5+
DOCKER_IMAGE_PLATFORM ?= linux/amd64
6+
7+
RUN = docker run -it --rm --entrypoint=bash -v .:/app "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)"
8+
BUILD = docker build --platform "$(DOCKER_IMAGE_PLATFORM)" -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)"
9+
10+
all: help
11+
12+
depends:
13+
ifeq ($(DOCKER_IMAGE_NAME),)
14+
@echo "DOCKER_IMAGE_NAME environment variable is required."
15+
@exit 1
16+
endif
17+
18+
build: depends
19+
$(BUILD) .
20+
21+
push: depends
22+
$(BUILD) . --push
23+
24+
run: depends
25+
$(RUN)
26+
27+
shell: depends
28+
$(RUN)
29+
30+
test: depends
31+
ifeq (,$(wildcard .plugin))
32+
git clone https://github.com/gocom/abc_plugin.git .plugin
33+
endif
34+
35+
docker run -it --rm -v .:/app --workdir /app/.plugin "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)"
36+
37+
help:
38+
@echo "Manage project"
39+
@echo ""
40+
@echo "Usage:"
41+
@echo " $$ make [command] ["
42+
@echo " [DOCKER_IMAGE_NAME=<image>]"
43+
@echo " [DOCKER_IMAGE_TAG=<tag>]"
44+
@echo " [DOCKER_IMAGE_PLATFORM=<platform>]"
45+
@echo " ]"
46+
@echo ""
47+
@echo "Commands:"
48+
@echo ""
49+
@echo " $$ make build"
50+
@echo " Build Docker image"
51+
@echo ""
52+
@echo " $$ make help"
53+
@echo " Print this message"
54+
@echo ""
55+
@echo " $$ make push"
56+
@echo " Build and push Docker image"
57+
@echo ""
58+
@echo " $$ make run"
59+
@echo " Run the built Docker image"
60+
@echo ""
61+
@echo " $$ make shell"
62+
@echo " Log in to the container"
63+
@echo ""
64+
@echo " $$ make test"
65+
@echo " Run smoke test"
66+
@echo ""

README.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ Package Textpattern CMS plugin GitHub Action
22
=====
33

44
This [GitHub Action](https://help.github.com/en/articles/about-github-actions) packages a source repository containing
5-
a [Textpattern CMS](https://textpattern.com) plugin and creates installers.
5+
a [Textpattern CMS](https://textpattern.com) plugin and creates installers using
6+
[mtxpc](https://github.com/gocom/MassPlugCompiler).
67

78
Usage
89
-----
@@ -41,21 +42,17 @@ See [rah_flat](https://github.com/gocom/rah_flat) repository for live
4142
Input Arguments
4243
-----
4344
44-
* **source**
45-
Path to the plugin source directory containing `manifest.json`. The path is relative to the repository root. Defaults
46-
to repository root directory.
47-
* **output**
48-
Path to the output directory where build artifacts are saved to, relative to `$GITHUB_WORKSPACE`. Defaults to
49-
`build/packages`.
45+
| Input | Description | Default |
46+
|----------|--------------------------------------------------------------------------------------------------------------|----------------------------------------|
47+
| `source` | Path to the plugin source directory containing `manifest.json`. The path is relative to the repository root. | Defaults to repository root directory. |
48+
| `output` | Path to the output directory where build artifacts are saved to, relative to `$GITHUB_WORKSPACE`. | `build/packages`. |
5049

5150
Output Variables
5251
-----
5352

54-
* **name**
55-
The name of the built plugin.
56-
* **version**
57-
The version number from the manifest file.
58-
* **compressed**
59-
Path to the compressed plugin installer file, relative to `$GITHUB_WORKSPACE`.
60-
* **uncompressed**
61-
Path to the uncompressed plugin installer file, relative to `$GITHUB_WORKSPACE`.
53+
| Output | Description |
54+
|----------------|----------------------------------------------------------------------------------|
55+
| `name` | The name of the built plugin. |
56+
| `version` | The version number from the manifest file. |
57+
| `compressed` | Path to the compressed plugin installer file, relative to `$GITHUB_WORKSPACE`. |
58+
| `uncompressed` | Path to the uncompressed plugin installer file, relative to `$GITHUB_WORKSPACE`. |

0 commit comments

Comments
 (0)