Skip to content

Commit

Permalink
ci: Support automated builds and versioning (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbmorley authored Mar 16, 2024
1 parent 339cb9f commit 1a0a685
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 6 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: build

on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
schedule:
- cron: '0 9 * * *'
workflow_dispatch:

jobs:
test:

name: build
runs-on: inseven-macos-14

steps:

- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Install dependencies
run: scripts/install-dependencies.sh

- name: Build
run: exec ./scripts/build.sh

- name: Release
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: scripts/release.sh

documentation-build:
runs-on: inseven-macos-14
steps:

- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build documentation
run: |
scripts/build-documentation.sh
chmod -v -R +rX "_site/"
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3

documentation-deploy:

needs: documentation-build
if: ${{ github.ref == 'refs/heads/main' }}

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # or the latest "vX.X.X" version tag for this action
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.DS_Store
.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.netrc
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
DerivedData/
_site
xcuserdata/

/*.xcodeproj
/Packages
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "scripts/changes"]
path = scripts/changes
url = https://github.com/jbmorley/changes.git
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ let package = Package(
],
dependencies: [
.package(path: "MacResources"),
.package(url: "https://github.com/inseven/interact.git", .upToNextMajor(from: "2.13.0")),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
.package(url: "https://github.com/inseven/interact.git", .upToNextMajor(from: "2.19.14")),
.package(url: "https://github.com/inseven/licensable.git", .upToNextMajor(from: "0.0.1")),
.package(url: "https://github.com/tribalworldwidelondon/CassowarySwift.git", from: "2.0.0"),
],
Expand Down
15 changes: 15 additions & 0 deletions scripts/build-documentation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

SCRIPT_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ROOT_DIRECTORY="${SCRIPT_DIRECTORY}/.."

cd "$ROOT_DIRECTORY"

swift package \
--allow-writing-to-directory _site \
generate-documentation \
--target SelectableCollectionView \
--output-path _site \
--disable-indexing \
--transform-for-static-hosting \
--hosting-base-path 'interact'
14 changes: 14 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e
set -o pipefail
set -x

SCRIPT_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ROOT_DIRECTORY="${SCRIPT_DIRECTORY}/.."

cd "$ROOT_DIRECTORY"

xcodebuild -scheme SelectableCollectionView -showdestinations
xcodebuild -scheme SelectableCollectionView -destination "platform=macOS" clean build
xcodebuild -scheme SelectableCollectionView -destination "platform=iOS Simulator,name=iPhone 14 Pro" clean build
1 change: 1 addition & 0 deletions scripts/changes
Submodule changes added at 12a6b9
31 changes: 31 additions & 0 deletions scripts/environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Copyright (c) 2018-2024 Jason Morley
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


SCRIPTS_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ROOT_DIRECTORY="${SCRIPTS_DIRECTORY}/.."

export PYTHONUSERBASE="${ROOT_DIRECTORY}/.local/python"
mkdir -p "$PYTHONUSERBASE"
export PATH="${PYTHONUSERBASE}/bin":$PATH

export PATH=$PATH:"${SCRIPTS_DIRECTORY}/changes"
37 changes: 37 additions & 0 deletions scripts/install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Copyright (c) 2018-2024 Jason Morley
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

set -e
set -o pipefail
set -x
set -u

SCRIPTS_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ROOT_DIRECTORY="${SCRIPTS_DIRECTORY}/.."
CHANGES_DIRECTORY="${SCRIPTS_DIRECTORY}/changes"

ENVIRONMENT_PATH="${SCRIPTS_DIRECTORY}/environment.sh"

source "$ENVIRONMENT_PATH"

# Install the Python dependencies
PIPENV_PIPFILE="$CHANGES_DIRECTORY/Pipfile" pipenv install
31 changes: 31 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Copyright (c) 2018-2024 Jason Morley
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

SCRIPTS_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ROOT_DIRECTORY="${SCRIPTS_DIRECTORY}/.."
CHANGES_DIRECTORY="${SCRIPTS_DIRECTORY}/changes"
CHANGES_SCRIPT="${CHANGES_DIRECTORY}/changes"
RELEASE_SCRIPT="${CHANGES_DIRECTORY}/examples/gh-release.sh"

source "${SCRIPTS_DIRECTORY}/environment.sh"

changes --verbose release --skip-if-empty --push --command "\"${RELEASE_SCRIPT}\"" "\"$@\""

0 comments on commit 1a0a685

Please sign in to comment.