From dd18ef302fa764d59dfd26b3a6da3623ce46c5f4 Mon Sep 17 00:00:00 2001 From: LizardByte-bot <108553330+LizardByte-bot@users.noreply.github.com> Date: Sun, 22 Oct 2023 15:50:12 -0400 Subject: [PATCH] ci: update global docker (#203) --- .github/workflows/ci-docker.yml | 140 +++++++++++--------------------- 1 file changed, 46 insertions(+), 94 deletions(-) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index edeeb2b..c8f0286 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -78,78 +78,37 @@ jobs: dockerfiles: ${{ steps.find.outputs.dockerfiles }} matrix: ${{ steps.find.outputs.matrix }} - check_changelog: - name: Check Changelog - needs: [check_dockerfiles] + setup_release: if: ${{ needs.check_dockerfiles.outputs.dockerfiles }} + name: Setup Release + needs: + - check_dockerfiles + outputs: + changelog_changes: ${{ steps.setup_release.outputs.changelog_changes }} + changelog_date: ${{ steps.setup_release.outputs.changelog_date }} + changelog_exists: ${{ steps.setup_release.outputs.changelog_exists }} + changelog_release_exists: ${{ steps.setup_release.outputs.changelog_release_exists }} + changelog_url: ${{ steps.setup_release.outputs.changelog_url }} + changelog_version: ${{ steps.setup_release.outputs.changelog_version }} + publish_pre_release: ${{ steps.setup_release.outputs.publish_pre_release }} + publish_release: ${{ steps.setup_release.outputs.publish_release }} + publish_stable_release: ${{ steps.setup_release.outputs.publish_stable_release }} + release_body: ${{ steps.setup_release.outputs.release_body }} + release_build: ${{ steps.setup_release.outputs.release_build }} + release_commit: ${{ steps.setup_release.outputs.release_commit }} + release_generate_release_notes: ${{ steps.setup_release.outputs.release_generate_release_notes }} + release_tag: ${{ steps.setup_release.outputs.release_tag }} + release_version: ${{ steps.setup_release.outputs.release_version }} runs-on: ubuntu-latest steps: - name: Checkout - if: ${{ github.ref == 'refs/heads/master' || github.base_ref == 'master' }} uses: actions/checkout@v4 - - name: Verify Changelog - id: verify_changelog - if: ${{ github.ref == 'refs/heads/master' || github.base_ref == 'master' }} - # base_ref for pull request check, ref for push - uses: LizardByte/.github/actions/verify_changelog@master + - name: Setup Release + id: setup_release + uses: LizardByte/setup-release-action@v2023.10.22-858d72b with: - token: ${{ secrets.GITHUB_TOKEN }} - outputs: - next_version: ${{ steps.verify_changelog.outputs.changelog_parser_version }} - next_version_bare: ${{ steps.verify_changelog.outputs.changelog_parser_version_bare }} - last_version: ${{ steps.verify_changelog.outputs.latest_release_tag_name }} - release_body: ${{ steps.verify_changelog.outputs.changelog_parser_description }} - - setup_release: - name: Setup Release - needs: check_changelog - runs-on: ubuntu-latest - steps: - - name: Set release details - id: release_details - env: - RELEASE_BODY: ${{ needs.check_changelog.outputs.release_body }} - run: | - # determine to create a release or not - if [[ $GITHUB_EVENT_NAME == "push" ]]; then - RELEASE=true - else - RELEASE=false - fi - - # set the release tag - COMMIT=${{ github.sha }} - if [[ $GITHUB_REF == refs/heads/master ]]; then - TAG="${{ needs.check_changelog.outputs.next_version }}" - RELEASE_NAME="${{ needs.check_changelog.outputs.next_version }}" - RELEASE_BODY="$RELEASE_BODY" - PRE_RELEASE="false" - elif [[ $GITHUB_REF == refs/heads/nightly ]]; then - TAG="nightly-dev" - RELEASE_NAME="nightly" - RELEASE_BODY="automated nightly release - $(date -u +'%Y-%m-%dT%H:%M:%SZ') - ${COMMIT}" - PRE_RELEASE="true" - fi - - echo "create_release=${RELEASE}" >> $GITHUB_OUTPUT - echo "release_tag=${TAG}" >> $GITHUB_OUTPUT - echo "release_commit=${COMMIT}" >> $GITHUB_OUTPUT - echo "release_name=${RELEASE_NAME}" >> $GITHUB_OUTPUT - echo "pre_release=${PRE_RELEASE}" >> $GITHUB_OUTPUT - - # this is stupid but works for multiline strings - echo "RELEASE_BODY<> $GITHUB_ENV - echo "$RELEASE_BODY" >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - - outputs: - create_release: ${{ steps.release_details.outputs.create_release }} - release_tag: ${{ steps.release_details.outputs.release_tag }} - release_commit: ${{ steps.release_details.outputs.release_commit }} - release_name: ${{ steps.release_details.outputs.release_name }} - release_body: ${{ env.RELEASE_BODY }} - pre_release: ${{ steps.release_details.outputs.pre_release }} + github_token: ${{ secrets.GITHUB_TOKEN }} lint_dockerfile: needs: [check_dockerfiles] @@ -180,7 +139,7 @@ jobs: cat "./hadolint.log" >> $GITHUB_STEP_SUMMARY docker: - needs: [check_dockerfiles, check_changelog, setup_release] + needs: [check_dockerfiles, setup_release] if: ${{ needs.check_dockerfiles.outputs.dockerfiles }} runs-on: ubuntu-latest permissions: @@ -210,24 +169,20 @@ jobs: - name: Prepare id: prepare env: - NV: ${{ needs.check_changelog.outputs.next_version }} + NV: ${{ needs.setup_release.outputs.release_tag }} run: | # get branch name BRANCH=${GITHUB_HEAD_REF} - RELEASE=false + RELEASE=${{ needs.setup_release.outputs.publish_release }} + COMMIT=${{ needs.setup_release.outputs.release_commit }} if [ -z "$BRANCH" ]; then echo "This is a PUSH event" BRANCH=${{ github.ref_name }} - COMMIT=${{ github.sha }} CLONE_URL=${{ github.event.repository.clone_url }} - if [[ $BRANCH == "master" ]]; then - RELEASE=true - fi else echo "This is a PULL REQUEST event" - COMMIT=${{ github.event.pull_request.head.sha }} CLONE_URL=${{ github.event.pull_request.head.repo.clone_url }} fi @@ -260,7 +215,7 @@ jobs: # parse custom directives out of dockerfile # try to get the platforms from the dockerfile custom directive, i.e. `# platforms: xxx,yyy` # directives for PR event, i.e. not push event - if [[ ${PUSH} == "false" ]]; then + if [[ ${RELEASE} == "false" ]]; then while read -r line; do if [[ $line == "# platforms_pr: "* && $PLATFORMS == "" ]]; then # echo the line and use `sed` to remove the custom directive @@ -299,13 +254,10 @@ jobs: echo "branch=${BRANCH}" >> $GITHUB_OUTPUT echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT - echo "commit=${COMMIT}" >> $GITHUB_OUTPUT echo "clone_url=${CLONE_URL}" >> $GITHUB_OUTPUT - echo "release=${RELEASE}" >> $GITHUB_OUTPUT echo "artifacts=${ARTIFACTS}" >> $GITHUB_OUTPUT echo "no_cache_filters=${NO_CACHE_FILTERS}" >> $GITHUB_OUTPUT echo "platforms=${PLATFORMS}" >> $GITHUB_OUTPUT - echo "push=${PUSH}" >> $GITHUB_OUTPUT echo "tags=${TAGS}" >> $GITHUB_OUTPUT - name: Set Up QEMU @@ -324,14 +276,14 @@ jobs: Docker-buildx${{ matrix.tag }}- - name: Log in to Docker Hub - if: ${{ steps.prepare.outputs.push == 'true' }} # PRs do not have access to secrets + if: ${{ needs.setup_release.outputs.publish_release == 'true' }} # PRs do not have access to secrets uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - name: Log in to the Container registry - if: ${{ steps.prepare.outputs.push == 'true' }} # PRs do not have access to secrets + if: ${{ needs.setup_release.outputs.publish_release == 'true' }} # PRs do not have access to secrets uses: docker/login-action@v3 with: registry: ghcr.io @@ -352,10 +304,10 @@ jobs: build-args: | BRANCH=${{ steps.prepare.outputs.branch }} BUILD_DATE=${{ steps.prepare.outputs.build_date }} - BUILD_VERSION=${{ needs.check_changelog.outputs.next_version }} - COMMIT=${{ steps.prepare.outputs.commit }} + BUILD_VERSION=${{ needs.setup_release.outputs.release_tag }} + COMMIT=${{ needs.setup_release.outputs.release_commit }} CLONE_URL=${{ steps.prepare.outputs.clone_url }} - RELEASE=${{ steps.prepare.outputs.release }} + RELEASE=${{ needs.setup_release.outputs.publish_release }} tags: ${{ steps.prepare.outputs.tags }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache @@ -367,15 +319,15 @@ jobs: with: context: ./ file: ${{ matrix.dockerfile }} - push: ${{ steps.prepare.outputs.push }} + push: ${{ needs.setup_release.outputs.publish_release }} platforms: ${{ steps.prepare.outputs.platforms }} build-args: | BRANCH=${{ steps.prepare.outputs.branch }} BUILD_DATE=${{ steps.prepare.outputs.build_date }} - BUILD_VERSION=${{ needs.check_changelog.outputs.next_version }} - COMMIT=${{ steps.prepare.outputs.commit }} + BUILD_VERSION=${{ needs.setup_release.outputs.release_tag }} + COMMIT=${{ needs.setup_release.outputs.release_commit }} CLONE_URL=${{ steps.prepare.outputs.clone_url }} - RELEASE=${{ steps.prepare.outputs.release }} + RELEASE=${{ needs.setup_release.outputs.publish_release }} tags: ${{ steps.prepare.outputs.tags }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache @@ -401,18 +353,18 @@ jobs: path: artifacts/ - name: Create/Update GitHub Release - if: ${{ needs.setup_release.outputs.create_release == 'true' && steps.prepare.outputs.artifacts == 'true' }} - uses: ncipollo/release-action@v1 + if: ${{ needs.setup_release.outputs.publish_release == 'true' && steps.prepare.outputs.artifacts == 'true' }} + uses: LizardByte/create-release-action@v2023.10.22-57d76be with: - name: ${{ needs.setup_release.outputs.release_name }} - tag: ${{ needs.setup_release.outputs.release_tag }} - commit: ${{ needs.setup_release.outputs.release_commit }} - artifacts: "*artifacts/*" - token: ${{ secrets.GH_BOT_TOKEN }} allowUpdates: true + artifacts: "*artifacts/*" body: ${{ needs.setup_release.outputs.release_body }} discussionCategory: announcements - prerelease: ${{ needs.setup_release.outputs.pre_release }} + generateReleaseNotes: ${{ needs.setup_release.outputs.release_generate_release_notes }} + name: ${{ needs.setup_release.outputs.release_tag }} + prerelease: ${{ needs.setup_release.outputs.publish_pre_release }} + tag: ${{ needs.setup_release.outputs.release_tag }} + token: ${{ secrets.GH_BOT_TOKEN }} - name: Update Docker Hub Description if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}