diff --git a/.github/workflows/deliver.yml b/.github/workflows/deliver.yml index 294d2cf3b..2d08914a7 100644 --- a/.github/workflows/deliver.yml +++ b/.github/workflows/deliver.yml @@ -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 @@ -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 diff --git a/docker/build-farmOS.sh b/docker/build-farmOS.sh index 87de2a201..2ca1b5502 100644 --- a/docker/build-farmOS.sh +++ b/docker/build-farmOS.sh @@ -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 @@ -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=(