Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/auto-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Auto Tag

on:
pull_request:
types:
- closed
branches:
- release

jobs:
auto-tag:
# 只在 PR 被合并时运行
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: release
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}

- name: Get version from commit
id: get_version
run: |
# 从最近的提交消息或版本文件中获取版本号
# 检查是否有版本号相关的提交
VERSION=$(git log -1 --pretty=%B | grep -oP '(?<=version |v)\d+\.\d+\.\d+' || echo "")

if [ -z "$VERSION" ]; then
# 如果提交消息中没有版本号,尝试从现有标签递增
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")
echo "Latest tag: $LATEST_TAG"

# 提取版本号并递增补丁版本
if [[ $LATEST_TAG =~ ^v?([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
MAJOR="${BASH_REMATCH[1]}"
MINOR="${BASH_REMATCH[2]}"
PATCH="${BASH_REMATCH[3]}"
PATCH=$((PATCH + 1))
VERSION="$MAJOR.$MINOR.$PATCH"
else
VERSION="1.0.0"
fi
fi

echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "New version will be: $VERSION"

- name: Check if tag exists
id: check_tag
run: |
VERSION="${{ steps.get_version.outputs.version }}"
if git rev-parse "$VERSION" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Tag $VERSION already exists"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Tag $VERSION does not exist"
fi

- name: Update version in source files
if: steps.check_tag.outputs.exists == 'false'
run: |
VERSION="${{ steps.get_version.outputs.version }}"

# 更新 Wallpapper/Program.swift 中的版本
sed -i "s/self\.consoleIO\.writeMessage(\"\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\")/self.consoleIO.writeMessage(\"$VERSION\")/" Sources/Wallpapper/Program.swift

# 更新 WallpapperExif/Program.swift 中的版本
sed -i "s/self\.consoleIO\.writeMessage(\"\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\")/self.consoleIO.writeMessage(\"$VERSION\")/" Sources/WallpapperExif/Program.swift

echo "Updated version to $VERSION in source files"

- name: Commit version changes
if: steps.check_tag.outputs.exists == 'false'
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.get_version.outputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# 检查是否有变更
if git diff --quiet; then
echo "No version changes to commit"
else
git add Sources/Wallpapper/Program.swift Sources/WallpapperExif/Program.swift
git commit -m "chore: bump version to $VERSION"
git push origin release
echo "Committed and pushed version changes"
fi

- name: Create and push tag
if: steps.check_tag.outputs.exists == 'false'
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.get_version.outputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$VERSION" -m "Release $VERSION"
git push origin "$VERSION"
echo "Created and pushed tag: $VERSION"
18 changes: 16 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,33 @@ name: Build

on:
push:
tags:
- '*'

jobs:
build:
runs-on: macos-latest

steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4

- name: Build
run: swift build --configuration release --arch arm64 --arch x86_64

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: wallpaper
path: |
.build/apple/Products/Release/wallpapper
.build/apple/Products/Release/wallpapper-exif

- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: |
.build/apple/Products/Release/wallpapper
.build/apple/Products/Release/wallpapper-exif
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 💻 wallpapper / wallpapper-exif

![Build Status](https://github.com/mczachurski/wallpapper/workflows/Build/badge.svg)
![Build Status](https://github.com/nodite/wallpapper/workflows/Build/badge.svg)
[![Swift 5.2](https://img.shields.io/badge/Swift-5.2-orange.svg?style=flat)](ttps://developer.apple.com/swift/)
[![Swift Package Manager](https://img.shields.io/badge/SPM-compatible-4BC51D.svg?style=flat)](https://swift.org/package-manager/)
[![Platforms OS X | Linux](https://img.shields.io/badge/Platforms-macOS%20-lightgray.svg?style=flat)](https://developer.apple.com/swift/)
Expand Down Expand Up @@ -32,7 +32,7 @@ You need to have latest XCode (10.2) and Swift 5 installed.
Open your terminal and run following commands.

```bash
brew tap mczachurski/wallpapper
brew tap nodite/wallpapper
brew install wallpapper
```

Expand All @@ -41,7 +41,7 @@ brew install wallpapper
Open your terminal and run following commands.

```bash
$ git clone https://github.com/mczachurski/wallpapper.git
$ git clone https://github.com/nodite/wallpapper.git
$ cd wallpapper
$ swift build --configuration release
$ sudo cp .build/release/wallpapper /usr/local/bin
Expand All @@ -53,7 +53,7 @@ If you are using swift in version 4.1, please edit `Package.swift` file and put
Also you can build using `build.sh` script (it uses `swiftc` instead Swift CLI).

```bash
$ git clone https://github.com/mczachurski/wallpapper.git
$ git clone https://github.com/nodite/wallpapper.git
$ cd wallpapper
$ ./build.sh
$ sudo cp .output/wallpapper /usr/local/bin
Expand All @@ -76,17 +76,17 @@ That's all. Now you can build your own dynamic wallpappers.

### Troubleshooting

If you get an error during the Swift build portion of install, try downloading the entire Xcode IDE (not just the tools) from the app store. Then run
If you get an error during the Swift build portion of install, try downloading the entire Xcode IDE (not just the tools) from the app store. Then run

```bash
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
```

and run the installation command again.

## Getting started

If you have done above commands now you can build dynamic wallpaper. It's really easy. First you have to put all you pictures into one folder and in the same folder create `json` file with picture's description. Application support three kinds of dynamic wallpapers.
If you have done above commands now you can build dynamic wallpaper. It's really easy. First you have to put all you pictures into one folder and in the same folder create `json` file with picture's description. Application support three kinds of dynamic wallpapers.

### Solar

Expand Down Expand Up @@ -165,7 +165,7 @@ Properties:

### Apperance

For wallpapers based on OS apperance settings (light/dark) we have to prepare much simpler JSON file, and we have to use only two images (one for light and one for dark theme).
For wallpapers based on OS apperance settings (light/dark) we have to prepare much simpler JSON file, and we have to use only two images (one for light and one for dark theme).

```json
[
Expand Down Expand Up @@ -196,7 +196,7 @@ When you have `json` file and all pictures then you can generate `heic` file. Yo
wallpapper -i wallpapper.json
```

You should got a new file: `output.heic`. Set this file as a new wallpaper and enjoy you own dynamic wallpaper!
You should got a new file: `output.heic`. Set this file as a new wallpaper and enjoy you own dynamic wallpaper!

### Extracting metadata

Expand Down