diff --git a/.github/actions/automatic-releases/action.yml b/.github/actions/automatic-releases/action.yml new file mode 100644 index 00000000..96c2afe8 --- /dev/null +++ b/.github/actions/automatic-releases/action.yml @@ -0,0 +1,20 @@ +# Definition of the github action +# as per https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action + +name: 'laminas/automatic-releases' +description: 'Automates automatic releases for semver-compliant repositories' + +inputs: + command-name: + description: | + Command to execute: one of + * `laminas:automatic-releases:release` + * `laminas:automatic-releases:create-merge-up-pull-request` + * `laminas:automatic-releases:switch-default-branch-to-next-minor` + required: true + +runs: + using: 'docker' + image: '../../../Dockerfile' + args: + - ${{ inputs.command-name }} diff --git a/.github/workflows/automatic-release.yml b/.github/workflows/automatic-release.yml index ad413043..6ef506cf 100644 --- a/.github/workflows/automatic-release.yml +++ b/.github/workflows/automatic-release.yml @@ -17,7 +17,7 @@ jobs: uses: "actions/checkout@v2" - name: "Release" - uses: "./" + uses: "./.github/actions/automatic-releases/" with: command-name: "laminas:automatic-releases:release" env: @@ -27,7 +27,7 @@ jobs: "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} - name: "Create Merge-Up Pull Request" - uses: "./" + uses: "./.github/actions/automatic-releases/" with: command-name: "laminas:automatic-releases:create-merge-up-pull-request" env: @@ -37,7 +37,7 @@ jobs: "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} - name: "Create and/or Switch to new Release Branch" - uses: "./" + uses: "./.github/actions/automatic-releases/" with: command-name: "laminas:automatic-releases:switch-default-branch-to-next-minor" env: @@ -47,7 +47,7 @@ jobs: "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} - name: "Bump Changelog Version On Originating Release Branch" - uses: "./" + uses: "./.github/actions/automatic-releases/" with: command-name: "laminas:automatic-releases:bump-changelog" env: @@ -57,7 +57,7 @@ jobs: "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} - name: "Create new milestones" - uses: "./" + uses: "./.github/actions/automatic-releases/" with: command-name: "laminas:automatic-releases:create-milestones" env: diff --git a/.github/workflows/build-and-push-containers.yml b/.github/workflows/build-and-push-containers.yml new file mode 100644 index 00000000..60561d0e --- /dev/null +++ b/.github/workflows/build-and-push-containers.yml @@ -0,0 +1,44 @@ +name: Build and push containers + +on: + release: + types: [published] + +jobs: + release-container: + runs-on: ubuntu-latest + steps: + - name: Compile tag list + id: tags + run: | + TAG=${GITHUB_REF#refs/tags/} + PREFIX=ghcr.io/laminas/automatic-releases + MAJOR="${PREFIX}:$(echo ${TAG} | cut -d. -f1)" + MINOR="${MAJOR}.$(echo ${TAG} | cut -d. -f2)" + PATCH="${PREFIX}:${TAG}" + echo "::set-output name=tags::[\"${MAJOR}\",\"${MINOR}\",\"${PATCH}\"]" + + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup QEMU + uses: docker/setup-qemu-action@v1 + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ secrets.AUTOMATIC_RELEASES_CONTAINER_USERNAME }} + password: ${{ secrets.AUTOMATIC_RELEASES_CONTAINER_PAT }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64 + push: true + tags: ${{ join(fromJSON(steps.tags.outputs.tags), ",") }} diff --git a/action.yml b/action.yml index eb23a714..391291f6 100644 --- a/action.yml +++ b/action.yml @@ -15,6 +15,6 @@ inputs: runs: using: 'docker' - image: 'Dockerfile' + image: 'docker://ghcr.io/laminas/automatic-releases:1' args: - ${{ inputs.command-name }}