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
38 changes: 38 additions & 0 deletions .github/workflows/build-appstore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

name: Prepare deployment to app store

on:
push:
branches:
- stable*

jobs:

build:
name: Create tagged release in stable branch
runs-on: ubuntu-22.04

defaults:
run:
shell: bash
working-directory: cookbook

if: github.actor != 'nextcloud-cookbook-bot'

steps:
- name: Checkout the project
uses: actions/checkout@v4
with:
path: cookbook
ref: ${{ github.ref }}
fetch-depth: 0

- name: Store the merge commit message in file
run: git log HEAD~1...HEAD --max-count=1 --format='%s%n%b' > /tmp/MERGE_COMMIT_MSG

- name: Bump the version
id: bump
run: ./.github/actions/deploy/create-version.sh /tmp/MERGE_COMMIT_MSG
env:
BOT_TOKEN: ${{ secrets.COOKBOOK_BOT_TOKEN }}

109 changes: 36 additions & 73 deletions .github/workflows/deploy-appstore.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@

name: Deploy to Appstore
name: Deploy to app store

on:
push:
branches:
- stable*

tags:
- v*
jobs:

deploy:
name: Deploy codebase
name: Deploy codebase to app store
runs-on: ubuntu-22.04

defaults:
run:
shell: bash
working-directory: cookbook

if: github.actor != 'nextcloud-cookbook-bot'
if: github.repository != 'christianlupus-nextcloud/cookbook-releases'

steps:
- name: Checkout the project
Expand All @@ -40,88 +39,52 @@ jobs:
restore-keys: |
${{ runner.os }}-node-${{ steps.date.outputs.date }}-
${{ runner.os }}-node-

- name: Store the merge commit message in file
run: git log HEAD~1...HEAD --max-count=1 --format='%s%n%b' > /tmp/MERGE_COMMIT_MSG

- name: Bump the version
id: bump
run: ./.github/actions/deploy/create-version.sh /tmp/MERGE_COMMIT_MSG
env:
BOT_TOKEN: ${{ secrets.COOKBOOK_BOT_TOKEN }}

- name: Install the NPM packages
run: npm ci

- name: Build NPM
run: npm run build

- name: Install composer packages
run: make composer_dist


- name: Extract app version
id: appversion
run: |
version=$(echo ${{ github.ref }} | sed 's@^refs/tags/@@;s@^v@@i')
echo -n "version=" >> $GITHUB_OUTPUT
echo "$version" >> $GITHUB_OUTPUT
if echo $version | grep '^[0-9]*\.[0-9]*\.[0-9]*$' > /dev/null
then
echo 'type=stable' >> $GITHUB_OUTPUT
else
echo 'type=beta' >> $GITHUB_OUTPUT
fi

- name: Build the appstore package
run: make appstore

- name: Move the tarball to temp folder
run: cp build/artifacts/appstore/cookbook.tar.gz /tmp
run: cp build/artifacts/appstore/cookbook.tar.gz /tmp/cookbook-${{ steps.appversion.outputs.version }}.tar.gz
- name: Show the size of the tarball
run: ls -lh /tmp/cookbook.tar.gz
run: ls -lh /tmp/cookbook-${{ steps.appversion.outputs.version }}.tar.gz

- name: Create the release in GitHub
uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
uses: softprops/[email protected]
id: release
with:
tag_name: v${{ steps.bump.outputs.version }}
release_name: "Version ${{ steps.bump.outputs.version }}"
draft: false
- name: Upload the asset to the version
uses: actions/[email protected]
id: upload_asset
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
upload_url: "${{ steps.create_release.outputs.upload_url }}"
asset_path: /tmp/cookbook.tar.gz
asset_name: Cookbook-${{ steps.bump.outputs.version }}.tar.gz
asset_content_type: application/gzip

- name: Output asset URL
run: echo "Download URL is ${{ steps.upload_asset.outputs.browser_download_url }}"
files: /tmp/cookbook-${{ steps.appversion.outputs.version }}.tar.gz
prerelease: "${{ steps.appversion.outputs.type == 'beta' }}"

- name: Save key in file
env:
PEM: ${{ secrets.APPSTORE_PRIV_KEY_PEM }}
run: |
touch /tmp/key.pem
chmod 600 /tmp/key.pem
echo "$PEM" > /tmp/key.pem
- name: Output asset URL
run: echo "Download URL is ${{ fromJSON(steps.release.outputs.assets)[0].browser_download_url }}"

- name: Upload app to Nextcloud appstore
uses: nextcloud-releases/nextcloud-appstore-push-action@a011fe619bcf6e77ddebc96f9908e1af4071b9c1 # v1
with:
app_name: cookbook
appstore_token: ${{ secrets.APPSTORE_TOKEN }}
download_url: ${{ fromJSON(steps.release.outputs.assets)[0].browser_download_url }}
app_private_key: ${{ secrets.PRIVATE_KEY }}

- name: Create a signature for the tarball
run: >-
openssl dgst -sha512
-sign /tmp/key.pem
/tmp/cookbook.tar.gz
| openssl base64
| tee /tmp/signature

- name: Register the release with the app store via REST API request
env:
TOKEN: ${{ secrets.APP_STORE_TOKEN }}
run: >-
CONTENT="{\"download\": \"${{ steps.upload_asset.outputs.browser_download_url }}\", \"signature\": \"$(cat /tmp/signature | tr -d '\n')\"}" &&
echo "$CONTENT" &&
curl_out=$(curl -X POST
https://apps.nextcloud.com/api/v1/apps/releases
-H "Authorization: Token $TOKEN"
-H "Content-Type: application/json"
-d "$CONTENT"
-w '\n%{http_code}\n');
ret=$? &&
code=$(echo "$curl_out" | tail -n 1) &&
msg=$(echo "$curl_out" | head -n -1) &&
echo "code=$code" >> $GITHUB_OUTPUT &&
echo "msg=$msg" >> $GITHUB_OUTPUT &&
echo "Result ($code): $msg" &&
echo "$code" | grep '^\([^45][0-9][0-9]\)$'
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
[#1803](https://github.com/nextcloud/cookbook/pull/1803) @christianlupus
- Fix building docker images for CI/automated tests
[#1810](https://github.com/nextcloud/cookbook/pull/1810) @christianlupus
- Reimplement appstore build scripts
[#1822](https://github.com/nextcloud/cookbook/pull/1822) @christianlupus


## 0.10.2 - 2023-03-24
Expand Down
25 changes: 22 additions & 3 deletions docs/dev/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ Now, you should create a pull request to merge the changes in the new `release/1
Do not yet merge the PR.
Here is the last chance to do some testing and verification.

### Let the actions do its magic
### Let Github actions create a tag for you

Now the critical part comes.
As soon as you merge the PR you set the gears into action and a new release will be published both on github and the NC appstore.
By merging the PR into `stable`, you trigger the generation of a tag in Github as well as some additional tasks.
This will **not yet** publish a release, just define the version to be used.

The important part is the commit message here.
It defines the type and the state of the release created.
For further information, read on.

#### Regular releases

Expand Down Expand Up @@ -95,6 +99,21 @@ Assume, you are on version `1.2.3`, the following table explains the resulting r
| `%MINOR% %PRE-RELEASE%alpha3%` | 1.3.0-alpha3 |
| `%PRE-RELEASE%beta.1% %MAJOR%` | 2.0.0-beta.1 |

### Fetch the created tag

After the action has run completely, you need locally to fetch the tags from the remote repository.
The new version should be downloaded as a tag `v1.2.4` automatically.

### Push the version to the appstore

Finally, the release can be published to the app store by pushing the pure tag to the release repository.
The Github actions there will build the app, create a release and finally trigger a new release in the Nextcloud app store.

**Attention:**
This is the final point where you have control over the process.
Once you pushed the tag to the releases repository, it will be published (unless a failure happens).
Undoing the publication needs manual intervention.

## Implementation details

The most recent version is stored in the files `major`, `minor`, and `patch` in `.github/actions/deploy/`.
Expand Down