Skip to content

Commit 3221dcb

Browse files
committed
Version 1
0 parents  commit 3221dcb

42 files changed

Lines changed: 6744 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release.yml

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
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

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Ignore built files
2+
*.zip
3+
4+
# Ignore IDE/editor-specific files
5+
.agent/
6+
.idea/
7+
.vscode/
8+
*.swp
9+
10+
# Ignore Node modules
11+
node_modules/
12+
13+
# Ignore macOS system files
14+
.DS_Store

.gitlab-ci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
image: ubuntu:latest
2+
3+
stages:
4+
- release
5+
6+
# --- CREATE THE RELEASE ---
7+
create_release:
8+
stage: release
9+
rules:
10+
# Only run this job when a tag is pushed to the main branch
11+
- if: '$CI_COMMIT_TAG'
12+
13+
before_script:
14+
# Install dependencies
15+
- apt-get update -y && apt-get install -y jq gettext libglib2.0-dev zip python3 curl git
16+
17+
# Install GitLab Release CLI
18+
- curl --location --output /usr/local/bin/release-cli "https://gitlab.com/api/v4/projects/gitlab-org%2Frelease-cli/packages/generic/release-cli/latest/release-cli-linux-amd64"
19+
- chmod +x /usr/local/bin/release-cli
20+
21+
script: |
22+
# Prepare Variables
23+
export RELEASE_VERSION="${CI_COMMIT_TAG#v}"
24+
export RELEASE_TITLE="Version $RELEASE_VERSION"
25+
26+
# Get the commit message for the description
27+
export RELEASE_DESCRIPTION=$(git log -1 --format=%B)
28+
29+
# Build the package
30+
./build.sh package
31+
32+
# Define Asset Name
33+
export ASSET_NAME=$(jq -r '.uuid' gnome-extensions/extension/metadata.json).zip
34+
35+
# Define the Package Registry URL
36+
export PACKAGE_REGISTRY_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${RELEASE_VERSION}/${ASSET_NAME}"
37+
38+
# Upload the ZIP file to GitLab Package Registry
39+
echo "Uploading ${ASSET_NAME}..."
40+
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${ASSET_NAME}" "${PACKAGE_REGISTRY_URL}"
41+
42+
# Prepare Safe Filepath
43+
SAFE_FILEPATH="/$(echo "$ASSET_NAME" | sed 's/@/-/g')"
44+
45+
# Prepare Assets Link JSON
46+
ASSETS_LINK_JSON=$(jq -n \
47+
--arg name "$ASSET_NAME" \
48+
--arg url "$PACKAGE_REGISTRY_URL" \
49+
--arg filepath "$SAFE_FILEPATH" \
50+
'{"name": $name, "url": $url, "filepath": $filepath}')
51+
52+
# Create the Release
53+
echo "Creating release..."
54+
release-cli create --name "$RELEASE_TITLE" --tag-name "$CI_COMMIT_TAG" \
55+
--description "$RELEASE_DESCRIPTION" \
56+
--assets-link "$ASSETS_LINK_JSON"

.prettierignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Ignore files for ESLint & Prettier
2+
eslint.config.js
3+
.prettierrc
4+
.prettierignore
5+
.stylelintrc.json
6+
7+
# Ignore extension metadata file
8+
metadata.json
9+
10+
# Ignore YAML configuration files
11+
*.yaml
12+
*.yml

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"printWidth": 200,
5+
"tabWidth": 4,
6+
"trailingComma": "all"
7+
}

.stylelintrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"rules": {
3+
"property-no-unknown": [
4+
true,
5+
{
6+
"ignoreProperties": ["background-gradient-direction", "background-gradient-start", "background-gradient-end", "icon-size", "spacing"]
7+
}
8+
]
9+
}
10+
}

build.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# --- Configuration & Argument Parsing ---
5+
TARGET=$1
6+
7+
# Check if a valid target was provided
8+
if [[ "$TARGET" != "review" && "$TARGET" != "package" ]]; then
9+
echo "Error: Invalid or missing target." >&2
10+
echo "Usage: $0 [review | package]" >&2
11+
echo " review - Build the source zip for extensions.gnome.org review" >&2
12+
echo " package - Build the installable package for GitHub Releases" >&2
13+
exit 1
14+
fi
15+
16+
# Read the UUID directly from the metadata.json inside the extension directory
17+
if ! EXTENSION_UUID=$(jq -r '.uuid' gnome-extensions/extension/metadata.json); then
18+
echo "Error: Could not parse UUID from gnome-extensions/extension/metadata.json." >&2
19+
echo "Please ensure 'jq' is installed and the file is correct." >&2
20+
exit 1
21+
fi
22+
23+
# --- Build Directory ---
24+
BUILD_DIR="build_temp"
25+
26+
# --- Set Zip Filename ---
27+
if [ "$TARGET" == "review" ]; then
28+
ZIP_FILE="${EXTENSION_UUID}-review.zip"
29+
echo "Building SOURCE zip for extensions.gnome.org review..."
30+
else # Target is "package"
31+
ZIP_FILE="${EXTENSION_UUID}.zip"
32+
echo "Building installable PACKAGE for distribution..."
33+
fi
34+
35+
# --- Main Script ---
36+
# 1. Clean up previous build artifacts
37+
echo "Cleaning up old build files..."
38+
rm -rf "$BUILD_DIR"
39+
rm -f "${EXTENSION_UUID}.zip" "${EXTENSION_UUID}-review.zip"
40+
41+
# 2. Create a fresh build directory and copy files
42+
echo "Copying all extension files..."
43+
mkdir -p "$BUILD_DIR"
44+
cp -r gnome-extensions/extension/* "$BUILD_DIR/"
45+
46+
# 3. Compile schemas only for the 'package' build
47+
if [ "$TARGET" == "package" ]; then
48+
echo "Compiling GSettings schema for package build..."
49+
glib-compile-schemas "$BUILD_DIR/schemas/"
50+
if [ $? -ne 0 ]; then
51+
echo "Error: Failed to compile schemas. Aborting." >&2
52+
exit 1
53+
fi
54+
else
55+
echo "Skipping schema compilation for review build."
56+
fi
57+
58+
# 4. Create the zip archive from the build directory
59+
echo "Creating zip file: $ZIP_FILE..."
60+
(cd "$BUILD_DIR" && zip -r "../$ZIP_FILE" . -x ".*" -x "__MACOSX")
61+
62+
# 5. Clean up the temporary build directory
63+
echo "Cleaning up temporary directory..."
64+
rm -rf "$BUILD_DIR"
65+
66+
# 6. Final success message
67+
echo "Build successful! Archive created at: $ZIP_FILE"

0 commit comments

Comments
 (0)