From 0e9c4fb0fad254fea93a59cf7dad4437af991391 Mon Sep 17 00:00:00 2001 From: Brett Hodges Date: Fri, 4 Oct 2024 16:48:28 -0500 Subject: [PATCH] Update platform-release.yaml --- .github/workflows/platform-release.yaml | 127 ++++++++++++++---------- 1 file changed, 76 insertions(+), 51 deletions(-) diff --git a/.github/workflows/platform-release.yaml b/.github/workflows/platform-release.yaml index 9c026adf..bf287b1c 100644 --- a/.github/workflows/platform-release.yaml +++ b/.github/workflows/platform-release.yaml @@ -147,33 +147,18 @@ jobs: path: | ./dist/*.tar.gz - # Creates a release with the artifacts from the previous steps. - # workflow_dispatch triggered versions will be draft releases. - # CLI docs are not updated for workflow_dispatch triggered versions. + release: runs-on: ubuntu-latest needs: [build-linux, build-macos, build-windows] steps: - # checkout the current repository - - name: Checkout kitops - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - # checkout the homebrew-kitops repository (jozu-ai/homebrew-kitops) - - name: Checkout homebrew-kitops - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - ###### CHANGE THIS TO jozu-ai/homebrew-kitops ###### - repository: brett-hodges/homebrew-kitops - ref: 'main' - path: homebrew-kitops - token: ${{ secrets.GITHUB_TOKEN }} - - name: Merge built artifacts uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.3 with: path: dist pattern: dist-* merge-multiple: true + - name: Create Checksums env: TAG_NAME: ${{ github.ref_name}} @@ -183,6 +168,11 @@ jobs: shasum -a 256 kitops-* > checksums.txt mv checksums.txt kitops_${TAG_NAME}_checksums.txt popd + + # checkout the current repository + - name: Checkout kitops + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + # uses the checksums created above to generate the homebrew recipe # file needed for the homebrew tap 'jozu-ai/homebrew-kitops' - name: Create Homebrew Formula @@ -208,9 +198,17 @@ jobs: popd pushd build/homebrew awk -f create-homebrew-recipe.awk homebrew-metadata.txt - cp kitops.rb ../../homebrew-kitops/. popd + - name: Upload Homebrew Formula As Artifact + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: homebrew-formula + if-no-files-found: error + retention-days: 7 + path: | + ./build/homebrew/kitops.rb + # Commit the Homebrew Formula to the current repo: jozu-ai/kitops - name: Commit Homebrew Formula env: @@ -233,31 +231,6 @@ jobs: gh pr create --fill --base main --head "${PR_BRANCH}" git checkout "${CURRENT_BRANCH}" - # Commit the Homebrew Formula to the repo: jozu-ai/homebrew-kitops - ##### CHANGE REPO TO jozu-ai/homebrew-kitops - - name: Commit Homebrew Formula to Tap - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAG_NAME: ${{ github.ref_name}} - REPO: "brett-hodges/homebrew-kitops" - run: | - pushd homebrew-kitops - CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) - PR_BRANCH="${{ github.ref_name }}-homebrew-tap-update" - git fetch origin main - git branch "$PR_BRANCH" - git checkout "$PR_BRANCH" - git pull origin --ff-only "${PR_BRANCH}" || true - git config --global user.name "${GITHUB_ACTOR}" - git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" - git add --all - git commit -m "homebrew: update Homebrew Tap Formula for ${{ github.ref_name }}" - git config --unset-all http.https://github.com/.extraheader - git push origin "${PR_BRANCH}" - gh pr create --fill --base main --head "${PR_BRANCH}" - git checkout "${CURRENT_BRANCH}" - popd - - name: Create Release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -268,11 +241,11 @@ jobs: echo "Creating release for ${TAG_NAME}" release_args=( ${TAG_NAME} - ./dist/*.* + ./dist/*.* --title "Release ${TAG_NAME}" --generate-notes --repo ${REPO} - ) + ) if [[ "${DRAFT_RELEASE}" == "false" ]]; then previous_release="$(gh release list --repo $REPO --limit 1 --json tagName --jq '.[] | .tagName ')" echo "Previous release: ${previous_release}" @@ -290,23 +263,75 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAG_NAME: ${{ inputs.release_tag || github.ref_name}} run: | + CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) + PR_BRANCH="${{ github.ref_name }}-docs-update" + git fetch origin main + git branch "$PR_BRANCH" + git checkout "$PR_BRANCH" + git pull origin --ff-only "${PR_BRANCH}" || true + + git config --global user.name "${GITHUB_ACTOR}" + git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" + + (cd docs; npm pkg set version=$TAG_NAME) + ./docs/src/docs/cli/generate.sh > /dev/null + git add --all + git commit -m "docs: update CLI documentation for ${{ github.ref_name }}" + git push origin "${PR_BRANCH}" + gh pr create --fill --base main --head "${PR_BRANCH}" + git checkout "${CURRENT_BRANCH}" + + + # Creates a release with the artifacts from the previous steps. + # workflow_dispatch triggered versions will be draft releases. + # CLI docs are not updated for workflow_dispatch triggered versions. + publish-homebrew-tap-formula: + runs-on: ubuntu-latest + needs: [release] + steps: + # checkout the homebrew-kitops repository (jozu-ai/homebrew-kitops) + - name: Checkout homebrew-kitops + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + ###### CHANGE THIS TO jozu-ai/homebrew-kitops ###### + repository: brett-hodges/homebrew-kitops + ref: 'main' + path: homebrew-kitops + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Download homebrew formula + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.3 + with: + path: homebrew-formula + name: homebrew-formula + + # Commit the Homebrew Formula to the repo: jozu-ai/homebrew-kitops + + - name: Commit Homebrew Formula to Tap + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG_NAME: ${{ github.ref_name}} + ##### CHANGE REPO TO jozu-ai/homebrew-kitops + REPO: "brett-hodges/homebrew-kitops" + run: | + ls + cp homebrew-formula homebrew-kitops/kitops.rb + pushd homebrew-kitops CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) - PR_BRANCH="${{ github.ref_name }}-docs-update" + PR_BRANCH="${{ github.ref_name }}-homebrew-tap-update" git fetch origin main git branch "$PR_BRANCH" git checkout "$PR_BRANCH" git pull origin --ff-only "${PR_BRANCH}" || true - git config --global user.name "${GITHUB_ACTOR}" git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" - - (cd docs; npm pkg set version=$TAG_NAME) - ./docs/src/docs/cli/generate.sh > /dev/null git add --all - git commit -m "docs: update CLI documentation for ${{ github.ref_name }}" + git commit -m "homebrew: update Homebrew Tap Formula for ${{ github.ref_name }}" + git config --unset-all http.https://github.com/.extraheader git push origin "${PR_BRANCH}" gh pr create --fill --base main --head "${PR_BRANCH}" git checkout "${CURRENT_BRANCH}" + popd docker-image-build: