Skip to content

Commit

Permalink
2.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
zm committed Apr 29, 2022
1 parent 6002d03 commit ae3daf6
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 69 deletions.
73 changes: 30 additions & 43 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

name: Deploy
name: Diana

on:
push:
Expand All @@ -8,61 +7,49 @@ on:

workflow_dispatch:

env:
APP_NAME: HostsX
SPARKLE_KEY: ${{ secrets.SPARKLE_KEY }}
BODY_PATH: BODY_PATH.md

jobs:

Deploy:
runs-on: macos-latest
Release:
runs-on: macos-12
steps:

- name: Checkout
uses: actions/checkout@v2.4.0


- name: Setup
uses: actions/setup-node@v3
with:
node-version: 18
- run: |
echo "APP_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Package
run: |
fastlane run increment_build_number build_number:${GITHUB_SHA::7}
fastlane package
- name: Create
run: |
brew install create-dmg
create-dmg \
--volicon AppIcon.icns \
--hdiutil-quiet \
--app-drop-link 0 30 \
$APP_SCHEME.dmg \
$APP_SCHEME.app
sh scripts/create_dmg.sh
- name: Update
run: |
build=`defaults read $PWD/$APP_SCHEME.app/Contents/Info.plist CFBundleVersion`

signature=`$PWD/sign_update -s $SPARKLE_KEY $APP_SCHEME.dmg`
signature=${signature%\" *}
signature=${signature#*=\"}

changelog=`cat CHANGELOG.md`
changelog=${changelog%%---*}
changelog=${changelog#*###}
changelog="###$changelog"
content="<!-- $build,$signature -->"

echo "$changelog$content" > CHANGELOG.md

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
body_path: CHANGELOG.md
files: ${{ env.APP_SCHEME }}.dmg
body_path: ${{ env.BODY_PATH }}
files: ${{ env.APP_NAME }}.dmg

- name: Appcast
run: |
curl -u ZzzM:$GITPAGE_TOKEN -X POST \
https://api.github.com/repos/${{ github.repository }}/pages/builds \
-H "Accept: application/vnd.github.mister-fantastic-preview+json"
env:
APP_SCHEME: ${{ secrets.APP_SCHEME }}
GITPAGE_TOKEN: ${{ secrets.GITPAGE_TOKEN }}
SPARKLE_KEY: ${{ secrets.SPARKLE_KEY }}
uses: actions/github-script@v6
if: startsWith(github.ref, 'refs/tags/')
with:
github-token: ${{ secrets.PERSONAL_TOKEN }}
script: |
github.rest.repos.requestPagesBuild({
owner: context.repo.owner,
repo: context.repo.repo,
})
Binary file removed AppIcon.icns
Binary file not shown.
19 changes: 15 additions & 4 deletions HostsX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
9828C8372772C3A800CC87BC /* NotificationHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9828C8362772C3A800CC87BC /* NotificationHelper.swift */; };
983E5367277367FD00CE84DE /* Help.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 983E5366277367FD00CE84DE /* Help.storyboard */; };
983E53692773696500CE84DE /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983E53682773696500CE84DE /* AboutViewController.swift */; };
9842E3412808031D00F218D8 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 9842E3402808031D00F218D8 /* Sparkle */; };
98526DC52769C40E00D84F87 /* Foundition+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98526DC42769C40E00D84F87 /* Foundition+.swift */; };
98526DC72769C44800D84F87 /* AppKit+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98526DC62769C44800D84F87 /* AppKit+.swift */; };
98706F6A276C37B500037F77 /* Menu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 98706F69276C37B500037F77 /* Menu.xib */; };
Expand Down Expand Up @@ -75,6 +76,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9842E3412808031D00F218D8 /* Sparkle in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -214,6 +216,7 @@
);
name = HostsX;
packageProductDependencies = (
9842E3402808031D00F218D8 /* Sparkle */,
);
productName = HostsX;
productReference = 98D573ED2758A0E2001C2D8C /* HostsX.app */;
Expand Down Expand Up @@ -245,7 +248,7 @@
);
mainGroup = 98D573E42758A0E2001C2D8C;
packageReferences = (
98FBFABF2806A51F0027D74C /* XCRemoteSwiftPackageReference "Sparkle" */,
9842E33F2808031D00F218D8 /* XCRemoteSwiftPackageReference "Sparkle" */,
);
productRefGroup = 98D573EE2758A0E2001C2D8C /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -463,7 +466,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 2.8.1;
MARKETING_VERSION = 2.8.2;
PRODUCT_BUNDLE_IDENTIFIER = com.alpha.hostsx;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -494,7 +497,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 2.8.1;
MARKETING_VERSION = 2.8.2;
PRODUCT_BUNDLE_IDENTIFIER = com.alpha.hostsx;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -527,7 +530,7 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
98FBFABF2806A51F0027D74C /* XCRemoteSwiftPackageReference "Sparkle" */ = {
9842E33F2808031D00F218D8 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sparkle-project/Sparkle";
requirement = {
Expand All @@ -536,6 +539,14 @@
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
9842E3402808031D00F218D8 /* Sparkle */ = {
isa = XCSwiftPackageProductDependency;
package = 9842E33F2808031D00F218D8 /* XCRemoteSwiftPackageReference "Sparkle" */;
productName = Sparkle;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 98D573E52758A0E2001C2D8C /* Project object */;
}
4 changes: 2 additions & 2 deletions HostsX/Base.lproj/Remote.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="46i-a3-Ebm">
<rect key="frame" x="13" y="10" width="369" height="14"/>
<textFieldCell key="cell" lineBreakMode="truncatingMiddle" alignment="left" title="Multiline Label" usesSingleLineMode="YES" id="Sho-ga-Kv3">
<font key="font" metaFont="system" size="11"/>
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="tertiaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
Expand All @@ -248,7 +248,7 @@
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Fwx-hk-JbJ">
<rect key="frame" x="31" y="5" width="29" height="11"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="origin" id="xLg-Pa-JXZ">
<font key="font" metaFont="system" size="9"/>
<font key="font" metaFont="miniSystem"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
Expand Down
10 changes: 7 additions & 3 deletions HostsX/Extension/AppKit+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ extension Bundle {
infoDictionary?["CFBundleName"] as? String
}

var shortVersion: String? {
var version: String? {
infoDictionary?["CFBundleShortVersionString"] as? String
}

var version: String? {
infoDictionary?["CFBundleVersion"] as? String
var commitHash: String? {
infoDictionary?["CommitHash"] as? String
}

var commitDate: String? {
infoDictionary?["CommitDate"] as? String
}

var humanReadableCopyright: String? {
Expand Down
4 changes: 4 additions & 0 deletions HostsX/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@
<string>https://zzzm.github.io/HostsX/appcast.xml</string>
<key>SUPublicEDKey</key>
<string>IqmAL/4PBUY1LejXocSszpdeqxAMQXLi3ydovPOOvvs=</string>
<key>CommitDate</key>
<string>CommitDate</string>
<key>CommitHash</key>
<string>CommitHash</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions HostsX/Menu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<menuItem title="Check for updates" id="GKT-X2-T5l">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="checkForUpdates:" target="uy0-JH-znn" id="ci5-UC-7J9"/>
<action selector="checkForUpdates:" target="fsD-U9-FQE" id="Ksf-kB-dnl"/>
</connections>
</menuItem>
<menuItem title="About" id="uNh-Vh-dFx">
Expand Down Expand Up @@ -83,6 +83,6 @@
</connections>
<point key="canvasLocation" x="113" y="106.5"/>
</menu>
<customObject id="uy0-JH-znn" customClass="SPUStandardUpdaterController"/>
<customObject id="fsD-U9-FQE" customClass="SPUStandardUpdaterController"/>
</objects>
</document>
4 changes: 2 additions & 2 deletions HostsX/Module/Help/AboutViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class AboutViewController: NSViewController {
private var name = Bundle.main.bundleName ?? "HostsX"

private var version: String {
guard let short = Bundle.main.shortVersion, let build = Bundle.main.version else {
guard let version = Bundle.main.version, let hash = Bundle.main.commitHash else {
return ""
}
return "\(Localization.About.version) \(short) (\(build))"
return "\(Localization.About.version) \(version) (\(hash))"
}
private var copyright = Bundle.main.humanReadableCopyright ?? ""

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ A lightweight macOS App for updating local hosts
- Requires **macOS 10.12** or later

## Changelogs
- [简体中文](CHANGELOG_SC.md)
- [English](CHANGELOG.md)
- [简体中文](changelogs/CHANGELOG_SC.md)
- [English](changelogs/CHANGELOG.md)

## Snapshots
- Menubar
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions CHANGELOG.md → changelogs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2.8.2 - 2022-04-29

### Fixed
- App update error

---

## 2.8.1 - 2022-04-06

### Changed
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG_SC.md → changelogs/CHANGELOG_SC.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2.8.2 - 2022-04-29

### Fixed
- 应用更新错误

---

## 2.8.1 - 2022-04-06

### Changed
Expand Down
25 changes: 19 additions & 6 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,37 @@ default_platform(:mac)

platform :mac do


lane :package do

setup
build
clean

end


private_lane :setup do
app_name = ENV["APP_NAME"]
commit = last_git_commit
date = Time.now.utc.localtime("+08:00").strftime("%Y.%m.%d %k:%M")
version = ENV["APP_VERSION"]
path = "#{app_name}/Info.plist"

increment_version_number_in_xcodeproj(version_number: version, scheme: app_name)
increment_build_number_in_xcodeproj(build_number: version, scheme: app_name)
set_info_plist_value(path: path, key: "CommitHash", value: commit[:abbreviated_commit_hash])
set_info_plist_value(path: path, key: "CommitDate", value: date)

end


lane :build do
private_lane :build do
build_app(
clean: true,
silent: true,
export_method: 'mac-application'
)
export_method: 'mac-application')
end

lane :clean do
private_lane :clean do
sh "rm -vfr ~/Library/Developer/Xcode/Archives/*"
end

Expand Down
5 changes: 0 additions & 5 deletions fastlane/Pluginfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!

gem 'fastlane-plugin-versioning'

gem 'fastlane-plugin-dmg'
38 changes: 38 additions & 0 deletions scripts/create_dmg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@


function transform() {
local changelog=`cat $1`
changelog=${changelog%%---*}
changelog=${changelog#*###}
changelog="###$changelog"
echo "$changelog<?"
}


function sparkle_enclosure() {
local signature=`$PWD/assets/sign_update -s $SPARKLE_KEY $APP_NAME.dmg`
local enclosure="<enclosure
url=\"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/$APP_VERSION/$APP_NAME.dmg\"
sparkle:version=\"$APP_VERSION\"
$signature
type=\"application/octet-stream\" />"
echo $enclosure
}

function generate_changlog() {
echo "$(transform changelogs/CHANGELOG.md)" > $BODY_PATH
echo "$(transform changelogs/CHANGELOG_SC.md)" >> $BODY_PATH
echo $(sparkle_enclosure) >> $BODY_PATH
}


function create_dmg() {
npm install --global create-dmg
create-dmg $APP_NAME.app
mv $APP_NAME*.dmg $APP_NAME.dmg
}

create_dmg
generate_changlog


0 comments on commit ae3daf6

Please sign in to comment.