Skip to content

Commit

Permalink
refactor(workflows): remove unnecessary shell declarations and stream…
Browse files Browse the repository at this point in the history
…line release tagging process
  • Loading branch information
Heavybullets8 committed Jan 6, 2025
1 parent 6a2cc26 commit 6b4563b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 36 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/helm-repository-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ jobs:
uses: actions/checkout@v4
with:
token: "${{ steps.app-token.outputs.token }}"
fetch-depth: 0

- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Setup Workflow Tools
shell: bash
run: brew install fluxcd/tap/flux

- if: ${{ github.event.inputs.helmRepoNamespace == '' && github.event.inputs.helmRepoName == '' }}
Expand All @@ -54,7 +52,6 @@ jobs:

- if: ${{ github.event.inputs.helmRepoNamespace == '' && github.event.inputs.helmRepoName == '' }}
name: Sync Helm Repository
shell: bash
run: |
declare -a repos=()
for f in ${{ steps.changed-files.outputs.all_changed_and_modified_files }}; do
Expand All @@ -71,7 +68,6 @@ jobs:
- if: ${{ github.event.inputs.helmRepoNamespace != '' && github.event.inputs.helmRepoName != '' }}
name: Sync Helm Repository
shell: bash
run: |
flux --namespace ${{ github.event.inputs.helmRepoNamespace }} \
reconcile source helm ${{ github.event.inputs.helmRepoName }} || true
reconcile source helm ${{ github.event.inputs.helmRepoName }} || true
3 changes: 0 additions & 3 deletions .github/workflows/pre-pull-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
- name: Extract Images
id: extract-images
shell: bash
run: |
images=$(yq --indent=0 --output-format=json \
'[.. | .images? | select(. != null)] | flatten | sort | unique' images.yaml \
Expand All @@ -70,7 +69,6 @@ jobs:
steps:
- name: Compare Images
id: compare-images
shell: bash
run: |
images=$(jq --compact-output --null-input \
--argjson f1 '${{ needs.extract-images.outputs.default }}' \
Expand All @@ -94,7 +92,6 @@ jobs:
uses: Homebrew/actions/setup-homebrew@master

- name: Setup Workflow Tools
shell: bash
run: brew install siderolabs/tap/talosctl

- name: Pre-pull Image
Expand Down
66 changes: 38 additions & 28 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,44 @@ jobs:
app-id: "${{ secrets.BOT_APP_ID }}"
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"

- name: Checkout
uses: actions/checkout@v4
- name: Get Previous Release Tag and Determine Next Tag
id: determine-next-tag
uses: actions/github-script@v7
with:
token: "${{ steps.app-token.outputs.token }}"
github-token: "${{ steps.app-token.outputs.token }}"
result-encoding: string
script: |
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 1,
});
let previousTag = "0.0.0"; // Default if no previous release exists
if (releases.length > 0) {
previousTag = releases[0].tag_name;
}
const [previousMajor, previousMinor, previousPatch] = previousTag.split('.').map(Number);
const currentYear = new Date().getFullYear();
const currentMonth = new Date().getMonth() + 1; // Months are 0-indexed in JavaScript
const nextMajorMinor = `${currentYear}.${currentMonth}`;
let nextPatch;
if (`${previousMajor}.${previousMinor}` === nextMajorMinor) {
console.log("Month release already exists for the year. Incrementing patch number by 1.");
nextPatch = previousPatch + 1;
} else {
console.log("Month release does not exist for the year. Starting with patch number 0.");
nextPatch = 0;
}
return `${nextMajorMinor}.${nextPatch}`;
- name: Create Release
shell: bash
env:
GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}"
run: |
# Retrieve previous release tag
previous_tag="$(gh release list --limit 1 | awk '{ print $1 }')"
previous_major="${previous_tag%%\.*}"
previous_minor="${previous_tag#*.}"
previous_minor="${previous_minor%.*}"
previous_patch="${previous_tag##*.}"
# Determine next release tag
next_major_minor="$(date +'%Y').$(date +'%-m')"
if [[ "${previous_major}.${previous_minor}" == "${next_major_minor}" ]]; then
echo "Month release already exists for year, incrementing patch number by 1"
next_patch="$((previous_patch + 1))"
else
echo "Month release does not exist for year, setting patch number to 0"
next_patch="0"
fi
# Create release
release_tag="${next_major_minor}.${next_patch}"
gh release create "${release_tag}" \
--repo="${GITHUB_REPOSITORY}" \
--title="${release_tag}" \
--generate-notes
uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
tag: "${{ steps.determine-next-tag.outputs.result }}"
token: "${{ steps.app-token.outputs.token }}"

0 comments on commit 6b4563b

Please sign in to comment.