Skip to content

Commit

Permalink
Update platform-release.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
brett-hodges committed Oct 4, 2024
1 parent ddacf0a commit 0e9c4fb
Showing 1 changed file with 76 additions and 51 deletions.
127 changes: 76 additions & 51 deletions .github/workflows/platform-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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 }}
Expand All @@ -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}"
Expand All @@ -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:
Expand Down

0 comments on commit 0e9c4fb

Please sign in to comment.