Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Few improvements and two useful examples added #9

Closed
wants to merge 10 commits into from
73 changes: 51 additions & 22 deletions README.md
@@ -1,22 +1,51 @@
## github-sfos-build
**GitHub-action for building Sailfish OS apps**

<br/>
For the available Sailfish OS build target releases, see https://hub.docker.com/r/coderus/sailfishos-platform-sdk/tags

#### Usage
* For Sailfish OS build target releases ≥ 4.1.0
```
uses: coderus/github-sfos-build@master
with:
release: <release>
arch: <arch>
```
* For Sailfish OS build target releases < 4.1.0
```
uses: coderus/github-sfos-build@old-stable
with:
release: <release>
arch: <arch>
```
For a complete example, [see here](https://github.com/storeman-developers/harbour-storeman/pull/170/files#diff-5c3fa597431eda03ac3339ae6bf7f05e1a50d6fc7333679ec38e21b337cb6721).
## Github action for building SailFish OS apps

For the available SailFish OS build target releases:

* https://hub.docker.com/r/coderus/sailfishos-platform-sdk/tags

or use `latest` to be always on the edge of the container updates.

---

### Usage

For Sailfish OS build target releases ≥ 4.1.0

```
uses: coderus/github-sfos-build@master
with:
release: <release>
arch: <arch>
```

For Sailfish OS build target releases < 4.1.0

```
uses: coderus/github-sfos-build@old-stable
with:
release: <release>
arch: <arch>
```

For a complete example, see [here](https://github.com/storeman-developers/harbour-storeman/pull/170/files#diff-5c3fa597431eda03ac3339ae6bf7f05e1a50d6fc7333679ec38e21b337cb6721).

---

### Useful cases

Three useful cases are listed here here below:

* [build on demand](examples/build-on-demand.yml)
* [build on pull](examples/build-on-pull.yml)
* [build on tags](examples/build-on-tags.yml)

Also build on tags can be run on-demand by user for test purposes but it also run when triggered by a tag set on the HEAD of the default branch. Therefore the last example includes and extend the functionality of the first one. About the *build on pull*, same story but triggered by a pull instead.

---

### Installation

Surf in the `Code` page of your Github project and then click on the `Action` button on the top menu. Click on the blue link *set up a workflow yourself*, change the filename `main.yml` in one more significative and the copy and paste into the content of one of the above examples and commit the changes.

To test your new action script, click on the `Action` button, select on the right list the script name you want to test and then on the left side click on *Run workflow*. In few seconds the workflow will start and in few minutes you will can download the results of the builing from the build script summary.
2 changes: 2 additions & 0 deletions action.yml
Expand Up @@ -18,3 +18,5 @@ runs:
env:
INPUT_RELEASE: ${{ inputs.release }}
INPUT_ARCH: ${{ inputs.arch }}
RELEASE: ${{ inputs.release }}
ARCH: ${{ inputs.arch }}
61 changes: 61 additions & 0 deletions examples/build-on-demand.yml
@@ -0,0 +1,61 @@
name: build on demand

env:
SFOS_RELEASE: 4.5.0.16

on:
workflow_dispatch:
branches:
- default

jobs:
build:
runs-on: ubuntu-20.04
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
steps:
- name: Checkout
uses: actions/checkout@v3

#RAF: Using the cache with docker requires that you have a dockerhub account and manage it as well.
# But it's much more powerful. Instead of saving just a directory, you will save an the docker.
# - name: Cache
# id: yamui-cache
# uses: actions/cache@v3
# with:
# path: RPMS
# key: ${{ runner.os }}-${{ cache.name }}-${{ hashFiles('**/lockfiles') }}
# restore-keys: |
# ${{ runner.os }}-yamui
# ${{ runner.os }}-

- name: Prepare
run: mkdir -p RPMS

- name: ARM64 build for ${{ env.ARCH }} on ${{ env.RELEASE }}
env:
ARCH: aarch64
RELEASE: ${{ env.SFOS_RELEASE }}
uses: robang74/github-sfos-apps-build@master
with:
release: ${{ env.RELEASE }}
arch: ${{ env.ARCH }}

- name: Upload build results
uses: actions/upload-artifact@v3
with:
name: RPMS build results
path: RPMS

- name: Create release
if: contains(github.ref, 'release')
run: |
set -x
assets=()
for asset in RPMS/*.rpm; do
assets+=("-a" "$asset")
done
tag_name="${GITHUB_REF##*/}"
hub release create "${assets[@]}" -m "$tag_name" "$tag_name"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71 changes: 71 additions & 0 deletions examples/build-on-pull.yml
@@ -0,0 +1,71 @@
name: build on pull

on:
pull_request:
branches:
- default
workflow_dispatch:
branches:
- default

env:
SFOS_RELEASE: 4.5.0.16

jobs:
build:
runs-on: ubuntu-22.04
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare
run: mkdir -p RPMS

- name: ARM64 build for ${{ env.ARCH }} on ${{ env.RELEASE }}
env:
ARCH: aarch64
RELEASE: ${{ env.SFOS_RELEASE }}
uses: robang74/github-sfos-apps-build@master
with:
release: ${{ env.RELEASE }}
arch: ${{ env.ARCH }}

- name: ARMv7 build for ${{ env.ARCH }} on ${{ env.RELEASE }}
env:
ARCH: armv7hl
RELEASE: ${{ env.SFOS_RELEASE }}
uses: robang74/github-sfos-apps-build@master
with:
release: ${{ env.RELEASE }}
arch: ${{ env.ARCH }}

- name: AMD86 build for ${{ env.ARCH }} on ${{ env.RELEASE }}
env:
ARCH: i486
RELEASE: ${{ env.SFOS_RELEASE }}
uses: robang74/github-sfos-apps-build@master
with:
release: ${{ env.RELEASE }}
arch: ${{ env.ARCH }}

- name: Upload build results
uses: actions/upload-artifact@v3
with:
name: RPMS build results
path: RPMS

# RAF: creating a release has been disabled because I want to keep the last created tag
# - name: Create release
# if: contains(github.ref, 'release')
# run: |
# set -x
# assets=()
# for asset in RPMS/*.rpm; do
# assets+=("-a" "$asset")
# done
# tag_name="${GITHUB_REF##*/}"
# hub release create "${assets[@]}" -m "$tag_name" "$tag_name"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73 changes: 73 additions & 0 deletions examples/build-on-tags.yml
@@ -0,0 +1,73 @@
name: build on tags

on:
push:
tags:
- '*'
# - 'v*[0-9]+.[0-9]+.*'
# - '^[0-9]+.[0-9]+.*'
workflow_dispatch:
branches:
- default

env:
SFOS_RELEASE: 4.5.0.16

jobs:
build:
runs-on: ubuntu-22.04
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare
run: mkdir -p RPMS

- name: ARM64 build for ${{ env.ARCH }} on ${{ env.RELEASE }}
env:
ARCH: aarch64
RELEASE: ${{ env.SFOS_RELEASE }}
uses: robang74/github-sfos-apps-build@master
with:
release: ${{ env.RELEASE }}
arch: ${{ env.ARCH }}

- name: ARMv7 build for ${{ env.ARCH }} on ${{ env.RELEASE }}
env:
ARCH: armv7hl
RELEASE: ${{ env.SFOS_RELEASE }}
uses: robang74/github-sfos-apps-build@master
with:
release: ${{ env.RELEASE }}
arch: ${{ env.ARCH }}

- name: AMD86 build for ${{ env.ARCH }} on ${{ env.RELEASE }}
env:
ARCH: i486
RELEASE: ${{ env.SFOS_RELEASE }}
uses: robang74/github-sfos-apps-build@master
with:
release: ${{ env.RELEASE }}
arch: ${{ env.ARCH }}

- name: Upload build results
uses: actions/upload-artifact@v3
with:
name: RPMS build results
path: RPMS

# RAF: creating a release has been disabled because I want to keep the last created tag
# - name: Create release
# if: contains(github.ref, 'release')
# run: |
# set -x
# assets=()
# for asset in RPMS/*.rpm; do
# assets+=("-a" "$asset")
# done
# tag_name="${GITHUB_REF##*/}"
# hub release create "${assets[@]}" -m "$tag_name" "$tag_name"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}