-
Notifications
You must be signed in to change notification settings - Fork 13
189 lines (151 loc) · 5.67 KB
/
Copy pathrelease.yml
File metadata and controls
189 lines (151 loc) · 5.67 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Release Workflow
on:
push:
branches:
- main
tags-ignore:
- '*'
jobs:
# --- JOB 1: UPDATE TRANSLATIONS ---
update-translations:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y gettext
- name: Update Templates
run: ./build.sh update-templates
- name: Commit and Push Changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Chore: Update translation templates"
file_pattern: "gnome-extensions/translation/"
commit_user_name: "GitHub Action Bot"
commit_user_email: "actions@github.com"
# --- JOB 2: VERIFY VERSION MATCH ---
verify-version-match:
needs: update-translations
if: startsWith(github.event.head_commit.message, 'Version ')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y jq
- name: Verify that commit version matches metadata.json
run: |
# Extract version from commit message (e.g., "3.0.0")
COMMIT_MSG="${{ github.event.head_commit.message }}"
COMMIT_VERSION=$(echo "$COMMIT_MSG" | sed -n 's/^Version \([0-9.]*\).*/\1/p')
# Extract version from metadata.json
METADATA_VERSION=$(jq -r '.version' gnome-extensions/extension/metadata.json)
echo "Version in commit message: $COMMIT_VERSION"
echo "Version in metadata.json: $METADATA_VERSION"
if [[ "$COMMIT_VERSION" != "$METADATA_VERSION" ]]; then
echo "::error::Version mismatch! Commit version is '$COMMIT_VERSION' but metadata.json version is '$METADATA_VERSION'."
exit 1
else
echo "Versions match. Proceeding with release."
fi
# --- JOB 3: CREATE THE RELEASE ---
create-release:
needs: verify-version-match
if: startsWith(github.event.head_commit.message, 'Version ')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Pull latest changes from bot
run: git pull origin main
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq gettext libglib2.0-dev zip
- name: Extract Version from Commit Message
run: |
COMMIT_MSG="${{ github.event.head_commit.message }}"
RELEASE_VERSION=$(echo "$COMMIT_MSG" | sed -n 's/^Version \([0-9.]*\).*/\1/p')
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
- name: Build the Extension Package
run: ./build.sh package
- name: Determine Asset Filename
run: echo "ASSET_NAME=$(jq -r '.uuid' gnome-extensions/extension/metadata.json).zip" >> $GITHUB_ENV
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.RELEASE_VERSION }}
name: ${{ github.event.head_commit.message }}
files: ${{ env.ASSET_NAME }}
generate_release_notes: true
# --- JOB 4: UPLOAD TO GNOME EXTENSIONS ---
upload-to-gnome-extensions:
needs: create-release
if: startsWith(github.event.head_commit.message, 'Version ')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Pull latest changes from bot
run: git pull origin main
- name: Install Dependencies for Build Script
run: |
sudo apt-get update
sudo apt-get install -y jq gettext libglib2.0-dev zip
- name: Run the Custom Build Process
run: ./build.sh review
- name: Rename Artifact for Upload Action
run: |
ORIGINAL_ZIP="$(jq -r '.uuid' gnome-extensions/extension/metadata.json)-review.zip"
RENAMED_ZIP="$(jq -r '.uuid' gnome-extensions/extension/metadata.json).shell-extension.zip"
mv "$ORIGINAL_ZIP" "$RENAMED_ZIP"
- name: Upload to GNOME Extensions
uses: murar8/gnome-extensions-action@0.1.0
with:
username: ${{ secrets.GNOME_USERNAME }}
password: ${{ secrets.GNOME_PASSWORD }}
accept-tos: true
source-dir: ''
# --- JOB 5: SYNC TO GITLAB ---
sync-to-gitlab:
needs: create-release
if: always() # This ensures it runs even if create-release is skipped.
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Pull latest changes from bot
run: |
git pull origin main
git fetch --tags origin
- name: Setup SSH Agent
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.KEY_GITHUB_GITLAB_SYNC }}
- name: Push to GitLab
run: |
echo "Syncing to GitLab..."
# Configure git
git config --global user.name "GitHub Action Bot"
git config --global user.email "actions@github.com"
# Add GitLab remote
ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
git remote add gitlab "git@gitlab.com:NiffirgkcaJ/${{ github.event.repository.name }}.git"
# Push to GitLab
echo "Pushing to GitLab..."
git push gitlab main --force
# Push tags to GitLab
echo "Pushing tags to GitLab..."
git push gitlab --tags --force