Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Test actions
on:
pull_request:
workflow_dispatch:

jobs:
shopware-version-fallback:
Expand Down Expand Up @@ -84,4 +85,32 @@ jobs:
if [[ "${SHOPWARE_VERSION}" != "${EXPECTED_VERSION}" ]]; then
echo "shopware-version should be '${EXPECTED_VERSION}' but got '${SHOPWARE_VERSION}'"
exit 1
fi

print-versions:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Get versions
id: versions
uses: ./versions
with:
github-token: ${{ github.token }}
- name: Print outputs
run: |
echo "next-minor: ${{ steps.versions.outputs.next-minor }}"
echo "next-patch: ${{ steps.versions.outputs.next-patch }}"
echo "latest: ${{ steps.versions.outputs.latest-version }}"
echo "first: ${{ steps.versions.outputs.first-version }}"
echo "lts-latest: ${{ steps.versions.outputs.lts-latest-version }}"
echo "lts-next-patch: ${{ steps.versions.outputs.lts-next-patch }}"
- name: Sanity-check next-minor
run: |
NEXT_MINOR="${{ steps.versions.outputs.next-minor }}"
if [[ ! "$NEXT_MINOR" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "next-minor looks wrong: '${NEXT_MINOR}'"
exit 1
fi
4 changes: 4 additions & 0 deletions versions/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ inputs:
lts-major:
description: LTS major prefix like v6.5.
default: v6.6.
github-token:
description: Token used to check for release branches via the GitHub API
default: ${{ github.token }}

outputs:
first-version:
Expand Down Expand Up @@ -47,5 +50,6 @@ runs:
env:
CUR_MAJOR: ${{ inputs.major }}
PREV_MAJOR: ${{ inputs.lts-major }}
GH_TOKEN: ${{ inputs.github-token }}
run: |
${GITHUB_ACTION_PATH}/print_versions.bash | tee >> "$GITHUB_OUTPUT"
11 changes: 10 additions & 1 deletion versions/print_versions.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/usr/bin/env bash

if ! gh auth status &>/dev/null; then
echo "::error::gh is not authenticated. Set GH_TOKEN or GITHUB_TOKEN." >&2
exit 1
fi

PREV_MAJOR="${PREV_MAJOR:-"v6.6."}"
CUR_MAJOR="${CUR_MAJOR:-"v6.7."}"

Expand All @@ -26,7 +31,11 @@ get_next_minor_and_patch() {
IFS='.' read -r -a parts <<<"${max_tag}"

local next_release_branch="${parts[0]#v}.${parts[1]}.$((${parts[2]} + 1)).x"
if gh api "repos/shopware/shopware/branches/${next_release_branch}" --silent 2>/dev/null; then
local gh_output gh_status
gh_output=$(gh api "repos/shopware/shopware/branches/${next_release_branch}" 2>&1)
gh_status=$?
if [ $gh_status -eq 0 ] || ! echo "$gh_output" | grep -q "HTTP 404"; then
# Branch exists, or the API call failed for an unknown reason — default to freeze.
echo "NEXT_MINOR=${parts[0]}.${parts[1]}.$((${parts[2]} + 2)).0"
else
echo "NEXT_MINOR=${parts[0]}.${parts[1]}.$((${parts[2]} + 1)).0"
Expand Down