ci: dynamic server version fetching
- Remove hardcoded GITCADDY_SERVER_VERSION - Each job fetches latest server version from API - Clear Go module cache before building plugins - Simplify server-release.yml to only create tags (no main commits) This ensures vault always builds against the correct server version.
This commit is contained in:
@@ -15,14 +15,18 @@ env:
|
||||
GOPRIVATE: git.marketally.com
|
||||
GONOSUMDB: git.marketally.com
|
||||
GO_VERSION: "1.25"
|
||||
# GitCaddy server version to build against (auto-updated by server release)
|
||||
GITCADDY_SERVER_VERSION: "v3.0.16"
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: linux-latest
|
||||
steps:
|
||||
- name: Get latest server version
|
||||
id: server
|
||||
run: |
|
||||
VERSION=$(curl -sf "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-server/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4)
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
@@ -34,8 +38,8 @@ jobs:
|
||||
|
||||
- name: Update replace directive for gitcaddy-server
|
||||
run: |
|
||||
# Replace local path with remote gitcaddy-server repo
|
||||
sed -i "s|replace code.gitcaddy.com/server/v3 => ../gitcaddy-server|replace code.gitcaddy.com/server/v3 => git.marketally.com/gitcaddy/gitcaddy-server/v3 ${{ env.GITCADDY_SERVER_VERSION }}|" go.mod
|
||||
SERVER_VERSION="${{ steps.server.outputs.version }}"
|
||||
sed -i "s|replace code.gitcaddy.com/server/v3 => ../gitcaddy-server|replace code.gitcaddy.com/server/v3 => git.marketally.com/gitcaddy/gitcaddy-server/v3 $SERVER_VERSION|" go.mod
|
||||
cat go.mod | grep -A2 "^replace"
|
||||
go mod tidy
|
||||
|
||||
@@ -46,6 +50,12 @@ jobs:
|
||||
name: Tests
|
||||
runs-on: linux-latest
|
||||
steps:
|
||||
- name: Get latest server version
|
||||
id: server
|
||||
run: |
|
||||
VERSION=$(curl -sf "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-server/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4)
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
@@ -57,7 +67,8 @@ jobs:
|
||||
|
||||
- name: Update replace directive for gitcaddy-server
|
||||
run: |
|
||||
sed -i "s|replace code.gitcaddy.com/server/v3 => ../gitcaddy-server|replace code.gitcaddy.com/server/v3 => git.marketally.com/gitcaddy/gitcaddy-server/v3 ${{ env.GITCADDY_SERVER_VERSION }}|" go.mod
|
||||
SERVER_VERSION="${{ steps.server.outputs.version }}"
|
||||
sed -i "s|replace code.gitcaddy.com/server/v3 => ../gitcaddy-server|replace code.gitcaddy.com/server/v3 => git.marketally.com/gitcaddy/gitcaddy-server/v3 $SERVER_VERSION|" go.mod
|
||||
go mod tidy
|
||||
|
||||
- name: Run tests
|
||||
@@ -112,6 +123,13 @@ jobs:
|
||||
needs: [lint, test, create-release]
|
||||
if: startsWith(github.ref, 'refs/tags/v') && needs.lint.result == 'success' && needs.create-release.result == 'success'
|
||||
steps:
|
||||
- name: Get latest server version
|
||||
id: server
|
||||
run: |
|
||||
VERSION=$(curl -sf "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-server/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4)
|
||||
echo "version=$VERSION"
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
@@ -121,9 +139,18 @@ jobs:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache: false
|
||||
|
||||
- name: Update replace directive for gitcaddy-server
|
||||
- name: Clear server module cache and update
|
||||
run: |
|
||||
sed -i "s|replace code.gitcaddy.com/server/v3 => ../gitcaddy-server|replace code.gitcaddy.com/server/v3 => git.marketally.com/gitcaddy/gitcaddy-server/v3 ${{ env.GITCADDY_SERVER_VERSION }}|" go.mod
|
||||
SERVER_VERSION="${{ steps.server.outputs.version }}"
|
||||
echo "Building against server $SERVER_VERSION"
|
||||
|
||||
# Clear any cached version of the server module
|
||||
rm -rf ~/go/pkg/mod/git.marketally.com/gitcaddy/gitcaddy-server* || true
|
||||
rm -rf ~/go/pkg/mod/cache/download/git.marketally.com/gitcaddy/gitcaddy-server* || true
|
||||
|
||||
# Update go.mod with the server version
|
||||
sed -i "s|replace code.gitcaddy.com/server/v3 => ../gitcaddy-server|replace code.gitcaddy.com/server/v3 => git.marketally.com/gitcaddy/gitcaddy-server/v3 $SERVER_VERSION|" go.mod
|
||||
cat go.mod | grep -A2 "^replace"
|
||||
go mod tidy
|
||||
|
||||
- name: Build plugin
|
||||
@@ -174,6 +201,13 @@ jobs:
|
||||
apt-get update
|
||||
apt-get install -y build-essential curl ca-certificates
|
||||
|
||||
- name: Get latest server version
|
||||
id: server
|
||||
run: |
|
||||
VERSION=$(curl -sf "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-server/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4)
|
||||
echo "version=$VERSION"
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Install Go
|
||||
run: |
|
||||
curl -fsSL "https://go.dev/dl/go1.25.6.linux-arm64.tar.gz" -o go.tar.gz
|
||||
@@ -185,9 +219,18 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Update replace directive for gitcaddy-server
|
||||
- name: Clear server module cache and update
|
||||
run: |
|
||||
sed -i "s|replace code.gitcaddy.com/server/v3 => ../gitcaddy-server|replace code.gitcaddy.com/server/v3 => git.marketally.com/gitcaddy/gitcaddy-server/v3 ${{ env.GITCADDY_SERVER_VERSION }}|" go.mod
|
||||
SERVER_VERSION="${{ steps.server.outputs.version }}"
|
||||
echo "Building against server $SERVER_VERSION"
|
||||
|
||||
# Clear any cached version of the server module
|
||||
rm -rf ~/go/pkg/mod/git.marketally.com/gitcaddy/gitcaddy-server* || true
|
||||
rm -rf ~/go/pkg/mod/cache/download/git.marketally.com/gitcaddy/gitcaddy-server* || true
|
||||
|
||||
# Update go.mod with the server version
|
||||
sed -i "s|replace code.gitcaddy.com/server/v3 => ../gitcaddy-server|replace code.gitcaddy.com/server/v3 => git.marketally.com/gitcaddy/gitcaddy-server/v3 $SERVER_VERSION|" go.mod
|
||||
cat go.mod | grep -A2 "^replace"
|
||||
/usr/local/go/bin/go mod tidy
|
||||
|
||||
- name: Build plugin
|
||||
@@ -238,6 +281,12 @@ jobs:
|
||||
- goos: windows
|
||||
goarch: amd64
|
||||
steps:
|
||||
- name: Get latest server version
|
||||
id: server
|
||||
run: |
|
||||
VERSION=$(curl -sf "https://direct.git.marketally.com/api/v1/repos/gitcaddy/gitcaddy-server/releases/latest" | grep -o '"tag_name":"[^"]*"' | cut -d'"' -f4)
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
@@ -249,7 +298,8 @@ jobs:
|
||||
|
||||
- name: Update replace directive for gitcaddy-server
|
||||
run: |
|
||||
sed -i "s|replace code.gitcaddy.com/server/v3 => ../gitcaddy-server|replace code.gitcaddy.com/server/v3 => git.marketally.com/gitcaddy/gitcaddy-server/v3 ${{ env.GITCADDY_SERVER_VERSION }}|" go.mod
|
||||
SERVER_VERSION="${{ steps.server.outputs.version }}"
|
||||
sed -i "s|replace code.gitcaddy.com/server/v3 => ../gitcaddy-server|replace code.gitcaddy.com/server/v3 => git.marketally.com/gitcaddy/gitcaddy-server/v3 $SERVER_VERSION|" go.mod
|
||||
go mod tidy
|
||||
|
||||
- name: Build keygen
|
||||
|
||||
@@ -8,14 +8,9 @@ on:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
env:
|
||||
GOPROXY: https://proxy.golang.org,direct
|
||||
GOPRIVATE: git.marketally.com
|
||||
GONOSUMDB: git.marketally.com
|
||||
|
||||
jobs:
|
||||
update-and-release:
|
||||
name: Update Server Version and Release
|
||||
create-release-tag:
|
||||
name: Create New Vault Release
|
||||
runs-on: linux-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -24,16 +19,12 @@ jobs:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.RELEASE_TOKEN }}
|
||||
|
||||
- name: Extract inputs
|
||||
id: payload
|
||||
run: |
|
||||
SERVER_TAG="${{ inputs.server_tag }}"
|
||||
echo "Server tag: $SERVER_TAG"
|
||||
echo "server_tag=$SERVER_TAG" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Determine next vault version
|
||||
id: version
|
||||
run: |
|
||||
SERVER_TAG="${{ inputs.server_tag }}"
|
||||
echo "Triggered by server $SERVER_TAG"
|
||||
|
||||
# Get the latest vault tag
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.0")
|
||||
echo "Latest vault tag: $LATEST_TAG"
|
||||
@@ -51,58 +42,22 @@ jobs:
|
||||
echo "New vault version: $NEW_VERSION"
|
||||
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Update build workflow with new server version
|
||||
run: |
|
||||
SERVER_TAG="${{ steps.payload.outputs.server_tag }}"
|
||||
|
||||
echo "Updating GITCADDY_SERVER_VERSION to $SERVER_TAG"
|
||||
|
||||
# Update the version in build.yml (simple tag format)
|
||||
sed -i "s|GITCADDY_SERVER_VERSION: \"v[0-9.]*\"|GITCADDY_SERVER_VERSION: \"$SERVER_TAG\"|" .gitea/workflows/build.yml
|
||||
|
||||
echo "Updated build.yml:"
|
||||
grep -A1 "GITCADDY_SERVER_VERSION" .gitea/workflows/build.yml
|
||||
|
||||
- name: Configure git
|
||||
run: |
|
||||
git config user.name "GitCaddy Bot"
|
||||
git config user.email "bot@gitcaddy.com"
|
||||
|
||||
- name: Commit and tag
|
||||
id: commit
|
||||
- name: Create and push tag
|
||||
run: |
|
||||
SERVER_TAG="${{ steps.payload.outputs.server_tag }}"
|
||||
SERVER_TAG="${{ inputs.server_tag }}"
|
||||
NEW_VERSION="${{ steps.version.outputs.new_version }}"
|
||||
|
||||
git add .gitea/workflows/build.yml
|
||||
|
||||
# Check if there are changes to commit
|
||||
if git diff --cached --quiet; then
|
||||
echo "No changes to commit - version already up to date"
|
||||
echo "has_changes=false" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "has_changes=true" >> "$GITHUB_OUTPUT"
|
||||
|
||||
git commit -m "build: auto-update server dependency to $SERVER_TAG
|
||||
|
||||
Triggered by server release $SERVER_TAG.
|
||||
Vault $NEW_VERSION is compatible with server $SERVER_TAG+.
|
||||
|
||||
🤖 Auto-generated by GitCaddy CI"
|
||||
|
||||
git tag -a "$NEW_VERSION" -m "Vault $NEW_VERSION for server $SERVER_TAG
|
||||
|
||||
This release is compatible with gitcaddy-server $SERVER_TAG and later.
|
||||
Build fetches server version dynamically from release API.
|
||||
|
||||
🤖 Auto-generated by GitCaddy CI"
|
||||
|
||||
echo "Created tag $NEW_VERSION"
|
||||
|
||||
- name: Push changes and tag
|
||||
if: steps.commit.outputs.has_changes == 'true'
|
||||
run: |
|
||||
git push origin main
|
||||
git push origin "${{ steps.version.outputs.new_version }}"
|
||||
echo "Pushed ${{ steps.version.outputs.new_version }} - build.yml will now trigger the full build"
|
||||
git push origin "$NEW_VERSION"
|
||||
echo "Pushed tag $NEW_VERSION - build.yml will now trigger the full build"
|
||||
|
||||
Reference in New Issue
Block a user