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
67 changes: 67 additions & 0 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

name: Userscripts deployment
on:
release:
types: [published] # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
jobs:
Deployment:
strategy:
matrix: # https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
platform: [mac, ios]
runs-on: macos-latest # https://github.com/actions/runner-images
steps:
- uses: actions/checkout@v4 # https://github.com/actions/checkout
with:
fetch-depth: 0
fetch-tags: true # https://github.com/actions/checkout/issues/1781
- uses: actions/setup-node@v4 # https://github.com/actions/setup-node
with:
node-version: latest
- id: semver # Parse semver from github ref
uses: userscriptsup/actions/semver-parser@main
- name: Verify release type
run: |
if ${{ github.event.release.prerelease }}; then
${{ steps.semver.outputs.beta }} || exit 11
else
${{ steps.semver.outputs.alpha }} && exit 12
${{ steps.semver.outputs.beta }} && exit 13
[ -n "${{ steps.semver.outputs.prerelease }}" ] && exit 14
exit 0
fi
- run: npm install
- run: npm run lint:js
- run: npm run lint:css
- run: npm run build:${{ matrix.platform }}-beta
if: ${{ github.event.release.prerelease }}
- run: npm run build:${{ matrix.platform }}
if: ${{ ! github.event.release.prerelease }}
- name: Set xcode version
run: sudo xcode-select -s "/Applications/Xcode_15.4.app" # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode
- name: Run fastlane
working-directory: ./fastlane
env:
FASTLANE_OPT_OUT_USAGE: "YES"
MATCH_GIT_URL: ${{ secrets.MATCH_GIT_URL }}
MATCH_GIT_PRIVATE_KEY: "fastlane/${{ secrets.GIT_PRIVATE_KEY_FILE }}"
GIT_PRIVATE_KEY_FILE: ${{ secrets.GIT_PRIVATE_KEY_FILE }}
GIT_PRIVATE_KEY_BASE64: ${{ secrets.GIT_PRIVATE_KEY_BASE64 }} # https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#storing-base64-binary-blobs-as-secrets
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
GYM_INSTALLER_CERT_NAME: ${{ secrets.GYM_INSTALLER_CERT_NAME }} # required for mac (unable to auto-detect)
APP_STORE_CONNECT_API_KEY_KEY_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY_ID }}
APP_STORE_CONNECT_API_KEY_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
APP_STORE_CONNECT_API_KEY_KEY: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY }}
MARKETING_VERSION: ${{ steps.semver.outputs.core }}
IS_PRERELEASE: ${{ github.event.release.prerelease }}
run: |
echo $GIT_PRIVATE_KEY_BASE64 | base64 --decode > $GIT_PRIVATE_KEY_FILE
chmod 600 $GIT_PRIVATE_KEY_FILE
bundle install
$IS_PRERELEASE && bundle exec fastlane ${{ matrix.platform }} beta
$IS_PRERELEASE || bundle exec fastlane ${{ matrix.platform }} release
- name: Artifact dSYM
uses: actions/upload-artifact@v4 # https://github.com/actions/upload-artifact
with:
name: Userscripts_${{ matrix.platform }}_${{ github.ref_name }}.app.dSYM
path: build/*.dSYM.zip
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ xcode/Ext-Safari/Resources/
# directories and files
local
*.local
/scripts/*.local.js
/scripts/*.local.js

# fastlane
/fastlane/report.xml
/fastlane/**/*.local.rb
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"[markdown]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
// https://github.com/microsoft/vscode-eslint#settings-options
"eslint.validate": ["javascript", "svelte"],
"eslint.experimental.useFlatConfig": true,
// https://github.com/stylelint/vscode-stylelint#stylelintvalidate
"stylelint.validate": ["css", "postcss", "svelte"]
}
14 changes: 14 additions & 0 deletions Userscripts.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// https://code.visualstudio.com/docs/editor/workspaces
{
"folders": [
{
"name": "Userscripts-JS",
"path": "."
},
{
"name": "Userscripts-Xcode",
"path": "xcode"
}
],
"settings": {}
}
4 changes: 4 additions & 0 deletions fastlane/Appfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# For more information about the Appfile, see:
# https://docs.fastlane.tools/advanced/#appfile

app_identifier("com.userscripts.macos")
75 changes: 75 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools

LOCAL_FASTFILE = "local/Fastfile.local.rb"
if File.file?(LOCAL_FASTFILE)
import(LOCAL_FASTFILE)
end

PROJECT_PATH = "xcode/Userscripts.xcodeproj"

# https://docs.fastlane.tools/actions/is_ci/
if is_ci
setup_ci
IS_CI = true
else
IS_CI = false
end

# https://docs.fastlane.tools/actions/app_store_connect_api_key/
app_store_connect_api_key(
key_id: ENV['APP_STORE_CONNECT_API_KEY_KEY_ID'],
issuer_id: ENV['APP_STORE_CONNECT_API_KEY_ISSUER_ID'],
key_content: ENV['APP_STORE_CONNECT_API_KEY_KEY'],
key_filepath: ENV['APP_STORE_CONNECT_API_KEY_KEY_FILEPATH'],
)

default_platform(:ios)

platform :ios do
lane :beta do
match
BUILD_NUMBER = latest_testflight_build_number(platform: "ios") + 1
build_app(
project: PROJECT_PATH,
scheme: "iOS",
xcargs: {
CURRENT_PROJECT_VERSION: BUILD_NUMBER.to_s,
MARKETING_VERSION: ENV['MARKETING_VERSION'],
},
output_directory: "build",
output_name: "Userscripts-iOS-Beta",
silent: IS_CI,
)
upload_to_testflight(skip_submission: true)
end

lane :release do
puts "ios release #{ENV['MARKETING_VERSION']}"
beta
end
end

platform :mac do
lane :beta do
match
BUILD_NUMBER = latest_testflight_build_number(platform: "osx") + 1
build_mac_app(
project: PROJECT_PATH,
scheme: "Mac",
xcargs: {
CURRENT_PROJECT_VERSION: BUILD_NUMBER.to_s,
MARKETING_VERSION: ENV['MARKETING_VERSION'],
},
output_directory: "build",
output_name: "Userscripts-Mac-Beta",
silent: IS_CI,
)
upload_to_testflight(skip_submission: true)
end

lane :release do
puts "mac release #{ENV['MARKETING_VERSION']}"
beta
end
end
4 changes: 4 additions & 0 deletions fastlane/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org"

gem "fastlane"
# gem "rubocop"
Loading