1+ name : Release Workflow
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ tags-ignore :
8+ - ' *'
9+
10+ jobs :
11+ # --- JOB 1: VERIFY VERSION MATCH ---
12+ verify-version-match :
13+ if : startsWith(github.event.head_commit.message, 'Version ')
14+ runs-on : ubuntu-latest
15+
16+ steps :
17+ - name : Checkout repository
18+ uses : actions/checkout@v4
19+
20+ - name : Install Dependencies
21+ run : sudo apt-get update && sudo apt-get install -y jq
22+
23+ - name : Verify that commit version matches metadata.json
24+ run : |
25+ # Extract version from commit message (e.g., "3.0.0")
26+ COMMIT_MSG="${{ github.event.head_commit.message }}"
27+ COMMIT_VERSION=$(echo "$COMMIT_MSG" | sed -n 's/^Version \([0-9.]*\).*/\1/p')
28+
29+ # Extract version from metadata.json
30+ METADATA_VERSION=$(jq -r '.version' gnome-extensions/extension/metadata.json)
31+
32+ echo "Version in commit message: $COMMIT_VERSION"
33+ echo "Version in metadata.json: $METADATA_VERSION"
34+
35+ if [[ "$COMMIT_VERSION" != "$METADATA_VERSION" ]]; then
36+ echo "::error::Version mismatch! Commit version is '$COMMIT_VERSION' but metadata.json version is '$METADATA_VERSION'."
37+ exit 1
38+ else
39+ echo "Versions match. Proceeding with release."
40+ fi
41+
42+ # --- JOB 2: CREATE THE RELEASE ---
43+ create-release :
44+ needs : verify-version-match
45+ if : startsWith(github.event.head_commit.message, 'Version ')
46+
47+ runs-on : ubuntu-latest
48+ permissions :
49+ contents : write
50+
51+ steps :
52+ - name : Checkout repository
53+ uses : actions/checkout@v4
54+ with :
55+ fetch-depth : 0
56+
57+ - name : Pull latest changes from bot
58+ run : git pull origin main
59+
60+ - name : Install Dependencies
61+ run : |
62+ sudo apt-get update
63+ sudo apt-get install -y jq gettext libglib2.0-dev zip
64+
65+ - name : Extract Version from Commit Message
66+ run : |
67+ COMMIT_MSG="${{ github.event.head_commit.message }}"
68+ RELEASE_VERSION=$(echo "$COMMIT_MSG" | sed -n 's/^Version \([0-9.]*\).*/\1/p')
69+ echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
70+
71+ - name : Build the Extension Package
72+ run : ./build.sh package
73+
74+ - name : Determine Asset Filename
75+ run : echo "ASSET_NAME=$(jq -r '.uuid' gnome-extensions/extension/metadata.json).zip" >> $GITHUB_ENV
76+
77+ - name : Create GitHub Release
78+ uses : softprops/action-gh-release@v2
79+ with :
80+ tag_name : v${{ env.RELEASE_VERSION }}
81+ name : ${{ github.event.head_commit.message }}
82+ files : ${{ env.ASSET_NAME }}
83+ generate_release_notes : true
84+
85+ # --- JOB 3: UPLOAD TO GNOME EXTENSIONS ---
86+ upload-to-gnome-extensions :
87+ needs : create-release
88+ if : startsWith(github.event.head_commit.message, 'Version ')
89+ runs-on : ubuntu-latest
90+
91+ steps :
92+ - name : Checkout repository
93+ uses : actions/checkout@v4
94+ with :
95+ fetch-depth : 0
96+
97+ - name : Pull latest changes from bot
98+ run : git pull origin main
99+
100+ - name : Install Dependencies for Build Script
101+ run : |
102+ sudo apt-get update
103+ sudo apt-get install -y jq gettext libglib2.0-dev zip
104+
105+ - name : Run the Custom Build Process
106+ run : ./build.sh review
107+
108+ - name : Rename Artifact for Upload Action
109+ run : |
110+ ORIGINAL_ZIP="$(jq -r '.uuid' gnome-extensions/extension/metadata.json)-review.zip"
111+ RENAMED_ZIP="$(jq -r '.uuid' gnome-extensions/extension/metadata.json).shell-extension.zip"
112+ mv "$ORIGINAL_ZIP" "$RENAMED_ZIP"
113+
114+ - name : Upload to GNOME Extensions
115+ uses : murar8/gnome-extensions-action@0.1.0
116+ with :
117+ username : ${{ secrets.GNOME_USERNAME }}
118+ password : ${{ secrets.GNOME_PASSWORD }}
119+ accept-tos : true
120+ source-dir : ' '
121+
122+ # --- JOB 4: SYNC TO GITLAB ---
123+ sync-to-gitlab :
124+ needs : create-release
125+ if : always() # This ensures it runs even if create-release is skipped.
126+ runs-on : ubuntu-latest
127+
128+ steps :
129+ - name : Checkout repository
130+ uses : actions/checkout@v4
131+ with :
132+ fetch-depth : 0
133+
134+ - name : Pull latest changes from bot
135+ run : |
136+ git pull origin main
137+ git fetch --tags origin
138+
139+ - name : Setup SSH Agent
140+ uses : webfactory/ssh-agent@v0.9.0
141+ with :
142+ ssh-private-key : ${{ secrets.KEY_GITHUB_GITLAB_SYNC }}
143+
144+ - name : Push to GitLab
145+ run : |
146+ echo "Syncing to GitLab..."
147+
148+ # Configure git
149+ git config --global user.name "GitHub Action Bot"
150+ git config --global user.email "actions@github.com"
151+
152+ # Add GitLab remote
153+ ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
154+ git remote add gitlab "git@gitlab.com:NiffirgkcaJ/${{ github.event.repository.name }}.git"
155+
156+ # Push to GitLab
157+ echo "Pushing to GitLab..."
158+ git push gitlab main --force
159+
160+ # Push tags to GitLab
161+ echo "Pushing tags to GitLab..."
162+ git push gitlab --tags --force
0 commit comments