Skip to content

Commit

Permalink
Build macos (#4)
Browse files Browse the repository at this point in the history
* add macos build

* update dimensions

* clippy

* refactor

* Update readme.md

* remove readme
  • Loading branch information
darrell-roberts authored Dec 30, 2024
1 parent f63e030 commit 3db636b
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 50 deletions.
74 changes: 37 additions & 37 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,43 @@ permissions:
contents: write

jobs:
# build-and-release-macos:
# runs-on: macos-latest

# steps:
# - name: Checkout repository
# uses: actions/checkout@v3

# - name: Setup Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# override: true

# - name: Setup Certificate
# env:
# CODE_SIGN_CERTIFICATE: ${{ secrets.CODE_SIGN_CERTIFICATE }}
# CERT_PWD: ${{ secrets.CERT_PWD }}
# run: |
# echo "$CODE_SIGN_CERTIFICATE" | base64 --decode > certificate.p12
# stat -f "%N %z" certificate.p12
# security create-keychain -p "" build.keychain
# security default-keychain -d user -s build.keychain
# security unlock-keychain -p "" build.keychain
# security import certificate.p12 -k build.keychain -P "$CERT_PWD" -T /usr/bin/codesign
# security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "" build.keychain

# - name: Build bundle
# run: make bundle-mac

# - name: Create GitHub Release
# id: create_release
# uses: softprops/action-gh-release@v1
# with:
# files: |
# dist/Hacker_News_aarch64.dmg.zip
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-and-release-macos:
runs-on: macos-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Setup Certificate
env:
CODE_SIGN_CERTIFICATE: ${{ secrets.CODE_SIGN_CERTIFICATE }}
CERT_PWD: ${{ secrets.CERT_PWD }}
run: |
echo "$CODE_SIGN_CERTIFICATE" | base64 --decode > certificate.p12
stat -f "%N %z" certificate.p12
security create-keychain -p "" build.keychain
security default-keychain -d user -s build.keychain
security unlock-keychain -p "" build.keychain
security import certificate.p12 -k build.keychain -P "$CERT_PWD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "" build.keychain
- name: Build bundle
run: make bundle-mac

- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v1
with:
files: |
dist/MineSweeper.dmg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-and-release-linux:
runs-on: ubuntu-latest
Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ bundle-mac: clean-dist build
# Copy application files
cp assets/icon.icns "dist/MineSweeper.app/Contents/Resources"
cp assets/Info.plist "dist/MineSweeper.app/Contents"
cp target/release/hacker-news-iced "dist/MineSweeper.app/Contents/MacOS"
chmod +x "dist/MineSweeper.app/Contents/MacOS/hacker-news-iced"
cp target/release/minesweeper-iced "dist/MineSweeper.app/Contents/MacOS"
chmod +x "dist/MineSweeper.app/Contents/MacOS/minesweeper-iced"

codesign --sign "MyApps" "dist/MineSweeper.app"

Expand All @@ -49,7 +49,6 @@ bundle-mac: clean-dist build

# Clean up
rm "dist/temp.dmg"
cd dist && zip -y "Hacker_News_aarch64.dmg.zip" "MineSweeper.dmg"

linux-app-image: clean-dist build
echo "Building linux app image"
Expand All @@ -70,8 +69,8 @@ install-local-linux: build
mkdir -p ~/.local/share/applications
mkdir -p ~/.local/share/icons
mkdir -p ~/.local/bin
cp target/release/hacker-news-iced ~/.local/bin
cp assets/hacker-news.desktop ~/.local/share/applications
cp target/release/minesweeper-iced ~/.local/bin
cp assets/minesweeper.desktop ~/.local/share/applications
cp -r assets/icons ~/.local/share/icons

install:
Expand Down
32 changes: 32 additions & 0 deletions assets/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>MineSweeper</string>
<key>CFBundleExecutable</key>
<string>minesweeper-iced</string>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
<key>CFBundleIdentifier</key>
<string>droberts-minesweeper</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>MineSweeper</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.0.1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
<key>LSMinimumSystemVersion</key>
<string>10.9</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
</dict>
</plist>
Binary file added assets/icon.icns
Binary file not shown.
3 changes: 0 additions & 3 deletions minesweeper-iced/readme.md

This file was deleted.

2 changes: 1 addition & 1 deletion minesweeper-iced/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn launch() -> iced::Result {
})
.theme(|_state| Theme::Dark)
.window(window::Settings {
size: (1024., 1124.).into(),
size: (900., 900.).into(),
#[cfg(target_os = "linux")]
platform_specific: window::settings::PlatformSpecific {
application_id: "minesweeper".into(),
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions minesweeper-iced/src/views/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl CellView {
}
};

container(content).width(45).height(45).into()
container(content).width(35).height(35).into()
}
}

Expand All @@ -95,5 +95,5 @@ fn cell_button<'a, Message>(content: impl Into<Element<'a, Message>>) -> Button<
where
Message: Clone + 'a,
{
button(content).width(45).height(45)
button(content).width(35).height(35)
}
2 changes: 1 addition & 1 deletion minesweeper/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl<'a> CellExpandIter<'a> {

/// An iterator that returns Positions that were opened from the starting
/// position.
impl<'a> Iterator for CellExpandIter<'a> {
impl Iterator for CellExpandIter<'_> {
type Item = (Pos, Cell);

fn next(&mut self) -> Option<Self::Item> {
Expand Down
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ https://user-images.githubusercontent.com/33698065/227748843-4da95c55-5bdf-4042-

An Iced UI for the minesweeper game.

<img width="712" alt="image" src="https://github.com/darrell-roberts/minesweeper/assets/33698065/81581b72-4370-4328-8ba7-9fd25d618621">
![Screenshot from 2024-12-30 11-20-52](https://github.com/user-attachments/assets/6fe28841-c3a8-4062-b4bb-3a23d9bf2f3b)

## Download
[Releases](https://github.com/darrell-roberts/minesweeper/releases)


## Build from source

Expand Down

0 comments on commit 3db636b

Please sign in to comment.