-
Notifications
You must be signed in to change notification settings - Fork 3
161 lines (136 loc) · 6.24 KB
/
Copy pathci.yml
File metadata and controls
161 lines (136 loc) · 6.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Deploy MkDocs Docs
on:
push:
branches:
- main
- "release-*" # Trigger on release-X.Y branches
permissions:
contents: write
pull-requests: write
jobs:
deploy:
runs-on: ubuntu-latest
concurrency:
group: docs-deploy
cancel-in-progress: false
steps:
- name: Checkout repo
uses: actions/checkout@v5
with:
fetch-depth: 0 # Important for mike to access full git history
- name: Extract version from branch name
id: version
run: |
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
echo "Branch name: $BRANCH_NAME"
if [[ "$BRANCH_NAME" == "main" ]]; then
VERSION="edge"
echo "Main branch detected, using edge version"
elif [[ "$BRANCH_NAME" =~ ^release-([0-9]+)\.([0-9]+)$ ]]; then
VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
echo "Release branch detected, extracted version: $VERSION"
else
echo "Error: Branch name must be 'main' or follow 'release-X.Y' format (e.g., release-1.0)"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
echo "Final version: $VERSION"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install dependencies
run: |
pip install -U -r requirements.txt
- name: Configure git user
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
- name: Deploy edge version (main branch)
if: github.ref == 'refs/heads/main'
run: |
mike deploy --push --update-aliases edge
- name: Get all existing versions for latest determination
if: startsWith(github.ref, 'refs/heads/release-')
id: get_versions
run: |
# Get all release branches and extract major.minor versions
git fetch origin
RELEASE_BRANCHES=$(git branch -r | grep 'origin/release-' | sed 's|.*origin/release-||' | grep -E '^[0-9]+\.[0-9]+$' | sort -V)
CURRENT_VERSION="${{ steps.version.outputs.version }}"
# Find the latest version from all release branches
LATEST_VERSION=$(echo "$RELEASE_BRANCHES" | tail -n 1)
LATEST_VERSION=${LATEST_VERSION:-$CURRENT_VERSION}
# Check if current version is the latest
if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
IS_LATEST="true"
else
IS_LATEST="false"
fi
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
echo "is_latest=$IS_LATEST" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"
echo "All release versions: $RELEASE_BRANCHES"
echo "Latest version: $LATEST_VERSION"
echo "Is latest: $IS_LATEST"
- name: Deploy release version
if: startsWith(github.ref, 'refs/heads/release-')
run: |
mike deploy --push --update-aliases "${{ steps.version.outputs.version }}"
- name: Update latest alias (only for actual latest version)
if: (startsWith(github.ref, 'refs/heads/release-')) && steps.get_versions.outputs.is_latest == 'true'
run: |
mike deploy --push --update-aliases "${{ steps.version.outputs.version }}" latest
mike set-default --push latest
echo "Updated latest alias to point to ${{ steps.version.outputs.version }}"
- name: Create or update git tag
if: startsWith(github.ref, 'refs/heads/release-')
run: |
TAG_NAME="v${{ steps.version.outputs.version }}"
echo "Creating/updating tag: $TAG_NAME"
# Delete existing tag if it exists (both locally and remotely)
if git tag -l | grep -q "^$TAG_NAME$"; then
echo "Tag $TAG_NAME already exists locally, deleting..."
git tag -d "$TAG_NAME"
fi
if git ls-remote --tags origin | grep -q "refs/tags/$TAG_NAME$"; then
echo "Tag $TAG_NAME exists on remote, deleting..."
git push origin ":refs/tags/$TAG_NAME"
fi
# Create new tag pointing to current commit
git tag "$TAG_NAME"
git push origin "$TAG_NAME"
echo "Tag $TAG_NAME created and pushed successfully"
- name: Create or update GitHub release
if: startsWith(github.ref, 'refs/heads/release-')
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ steps.version.outputs.version }}"
name: "Release v${{ steps.version.outputs.version }}"
body: |
## 3D City Database Documentation v${{ steps.version.outputs.version }}
This release contains the documentation for 3D City Database version ${{ steps.version.outputs.version }}.
📖 **Documentation**: https://docs.3dcitydb.org/
🏷️ **Version**: ${{ steps.version.outputs.version }}
🌿 **Branch**: ${{ steps.version.outputs.branch_name }}
### Access the documentation
- **Latest stable**: https://docs.3dcitydb.org/
- **This version**: https://docs.3dcitydb.org/${{ steps.version.outputs.version }}/
draft: false
prerelease: false
make_latest: ${{ steps.get_versions.outputs.is_latest == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update previous latest release
if: (startsWith(github.ref, 'refs/heads/release-')) && steps.get_versions.outputs.is_latest == 'true' && steps.get_versions.outputs.current_version != steps.get_versions.outputs.latest_version
run: |
# Find and update the previous latest release
PREVIOUS_LATEST=$(gh release list --limit 100 --json tagName,isLatest --jq '.[] | select(.isLatest == true) | .tagName')
if [ ! -z "$PREVIOUS_LATEST" ] && [ "$PREVIOUS_LATEST" != "v${{ steps.version.outputs.version }}" ]; then
echo "Updating previous latest release: $PREVIOUS_LATEST"
gh release edit "$PREVIOUS_LATEST" --latest=false
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}