Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag new releases of farmOS/composer-project when a new version of farmOS is tagged #739

Draft
wants to merge 4 commits into
base: 2.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 19 additions & 2 deletions .github/workflows/deliver.yml
Expand Up @@ -130,8 +130,10 @@ jobs:
- name: Test Drush site install with all modules
run: docker compose exec -u www-data -T www drush site-install --db-url=${{ matrix.DB_URL }} farm farm.modules='all'
release:
name: Create GitHub release
if: github.event_name == 'push' && github.ref_type == 'tag'
name: Create release
# We only create a release if this is a tag push event to the official
# repository.
if: github.repository == 'farmOS/farmOS' && github.event_name == 'push' && github.ref_type == 'tag'
runs-on: ubuntu-latest
needs:
- build
Expand Down Expand Up @@ -159,6 +161,21 @@ jobs:
files: /tmp/farmOS-${{ env.FARMOS_VERSION }}.tar.gz
draft: false
prerelease: false
- name: Checkout the farmOS/composer-project repository
uses: actions/checkout@v3
with:
repository: farmOS/composer-project
ref: 2.x
path: composer-project
- name: Tag a new release of farmOS/composer-project
run: |
cd composer-project
cp /tmp/farmOS/composer.json ./
cp /tmp/farmOS/composer.lock ./
git add .
git commit -m 'farmOS ${{ env.FARMOS_VERSION }}'
git tag ${{ env.FARMOS_VERSION }}
git push origin ${{ env.FARMOS_VERSION }}
publish:
name: Publish to Docker Hub
# We only publish to Docker Hub if this is a tag or 2.x branch push event
Expand Down
17 changes: 13 additions & 4 deletions docker/build-farmOS.sh
Expand Up @@ -23,8 +23,17 @@ git reset --hard
# Create a temporary Composer cache directory.
export COMPOSER_HOME="$(mktemp -d)"

# Add the farmOS repository to composer.json.
composer config repositories.farmos git ${FARMOS_REPO}
# If FARMOS_VERSION is a valid semantic versioning string, we assume that it is
# a tagged version.
IS_TAGGED_RELEASE=false
if [[ "${FARMOS_VERSION}" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
IS_TAGGED_RELEASE=true
fi

# Add the farmOS repository to composer.json (if this is not a tagged release).
if [[ ! ${IS_TAGGED_RELEASE} ]]; then
composer config repositories.farmos git ${FARMOS_REPO}
fi

# Require the correct farmOS version in composer.json. Defaults to 2.x.
# If FARMOS_VERSION is not a valid semantic versioning string, we assume that
Expand All @@ -33,10 +42,10 @@ composer config repositories.farmos git ${FARMOS_REPO}
# that it is a tagged version and require that version.
if [ "${FARMOS_VERSION}" = "2.x" ]; then
FARMOS_COMPOSER_VERSION="2.x-dev"
elif [[ ! "${FARMOS_VERSION}" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
elif [[ ! ${IS_TAGGED_RELEASE} ]]; then
FARMOS_COMPOSER_VERSION="dev-${FARMOS_VERSION}"
fi
composer require farmos/farmos ${FARMOS_COMPOSER_VERSION} --no-install
composer require farmos/farmos:${FARMOS_COMPOSER_VERSION} --no-install

# Add allow-plugins config.
allowedPlugins=(
Expand Down