Pico/Makefile
Daniel Rudolf 60d0f5403c
CI: Use build script to publish new releases
Since Pico depends on PicoDeprecated, and PicoDeprecated depends on Pico, a chicken-egg-problem arises: When pushing a new tag for Pico, GitHub Actions will try to build this new release by downloading the matching version of PicoDeprecated from Packagist. Since we didn't release a new version of PicoDeprecated yet, this will fail. So we need to push PicoDeprecated's tag first. Doing so yields GitHub Actions trying to build PicoDeprecated's new release - by trying to download the matching version of Pico from Packagist, which doesn't exist yet.

Thus builds will always fail - unless you push both tags at the exact same time, and unless you send some prayers that GitHub Actions delays building until Packagist picks up the new releases. The simplest solution is not to use GitHub Actions to publish new releases, but letting the user to do it instead. With this changeset this is as simple as `make publish version=v3.0.0`. The 'deploy-release' GitHub workflow now just updates the website and is triggered by publishing the GitHub release, not the tag. This additionally allows the user to perform some manual tests before publication.

The build script now depends on GitHub CLI (`gh`), see https://cli.github.com/. You must setup authentication first (`gh auth login`).
2022-03-08 22:07:35 +01:00

56 lines
1.3 KiB
Makefile

# Pico -- Makefile
# Makefile to build new Pico releases using './.build/build.sh'.
#
# This file is part of Pico, a stupidly simple, blazing fast, flat file CMS.
# Visit us at https://picocms.org/ for more info.
#
# Copyright (c) 2022 Daniel Rudolf <https://www.daniel-rudolf.de>
#
# This work is licensed under the terms of the MIT license.
# For a copy, see LICENSE file or <https://opensource.org/licenses/MIT>.
#
# SPDX-License-Identifier: MIT
# License-Filename: LICENSE
version?=
nocheck?=false
publish=false
php?=php
composer?=composer
app_name=pico
archive_tar=$(app_name)-release-*.tar.gz
archive_zip=$(app_name)-release-*.zip
export=$(app_name)-export.tar.gz
all: clean build
clean: clean-build clean-export
clean-build:
find "." -name "$(archive_tar)" -exec rm -f {} \;
find "." -name "$(archive_zip)" -exec rm -f {} \;
clean-export:
rm -f "./$(export)"
build: export PHP=$(php)
build: export COMPOSER=$(composer)
build:
./.build/build.sh$(if $(filter true,$(publish)), --publish,)$(if $(filter true,$(nocheck)), --no-check,)$(if $(version), "$(version)",)
export:
git archive --prefix "$(app_name)/" -o "./$(export)" HEAD
publish: publish=true
publish: build
composer:
$(composer) install --optimize-autoloader --no-dev
.PHONY: all \
clean clean-build clean-export \
build export publish \
composer