Skip to content

Commit 8dbdceb

Browse files
committed
Refactor appstore publish workflows
1 parent df614bf commit 8dbdceb

6 files changed

Lines changed: 1633 additions & 80 deletions

File tree

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Appstore Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
- main
8+
workflow_dispatch:
9+
inputs:
10+
channel:
11+
description: Publish channel; rc is reserved for manual pre-release use
12+
required: true
13+
type: choice
14+
options:
15+
- dev
16+
- rc
17+
- release
18+
from_ref:
19+
description: Optional git ref used to calculate apps-delta
20+
required: false
21+
type: string
22+
23+
jobs:
24+
publish:
25+
name: Build and publish appstore artifacts
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Check out code
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Resolve publish channel
35+
id: resolve_channel
36+
run: |
37+
if [[ "${{ github.event_name }}" == "push" ]]; then
38+
if [[ "${{ github.ref_name }}" == "dev" ]]; then
39+
channel="dev"
40+
elif [[ "${{ github.ref_name }}" == "main" ]]; then
41+
channel="release"
42+
else
43+
echo "Unsupported push branch: ${{ github.ref_name }}" >&2
44+
exit 1
45+
fi
46+
else
47+
channel="${{ inputs.channel }}"
48+
fi
49+
50+
echo "channel=$channel" >> "$GITHUB_OUTPUT"
51+
52+
- name: Set up Python
53+
uses: actions/setup-python@v5
54+
with:
55+
python-version: '3.11'
56+
57+
- name: Install Python dependencies
58+
run: |
59+
python -m pip install --upgrade pip
60+
pip install requests
61+
62+
- name: Fetch catalog inputs
63+
env:
64+
CONTENTFUL_GRAPHQL_TOKEN: ${{ secrets.CONTENTFUL_GRAPHQLTOKEN }}
65+
run: |
66+
python build/fetch_catalog.py \
67+
--channel "${{ steps.resolve_channel.outputs.channel }}" \
68+
--output-dir dist/catalog-source
69+
70+
- name: Build publish artifacts
71+
run: |
72+
args=(
73+
--channel "${{ steps.resolve_channel.outputs.channel }}"
74+
--output-dir dist/appstore-publish
75+
--catalog-source-dir dist/catalog-source
76+
)
77+
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.from_ref }}" ]]; then
78+
args+=(--from-ref "${{ inputs.from_ref }}")
79+
fi
80+
python build/library_publish.py "${args[@]}"
81+
82+
- name: Upload workflow artifact
83+
uses: actions/upload-artifact@v4
84+
with:
85+
name: appstore-publish-${{ steps.resolve_channel.outputs.channel }}
86+
path: dist/appstore-publish
87+
88+
- name: Upload v2 artifacts to Cloudflare R2
89+
uses: ryand56/r2-upload-action@latest
90+
with:
91+
r2-account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
92+
r2-access-key-id: ${{ secrets.CLOUDFLARE_R2_SECRET_ID }}
93+
r2-secret-access-key: ${{ secrets.CLOUDFLARE_R2_SECRET_KEY }}
94+
r2-bucket: artifact
95+
source-dir: dist/appstore-publish/v2/${{ steps.resolve_channel.outputs.channel }}/appstore
96+
destination-dir: ./websoft9/v2/${{ steps.resolve_channel.outputs.channel }}/appstore

.github/workflows/release-dev.yml

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,70 @@
11
name: Release library and media to artifact(dev)
22

33
on:
4-
# push:
5-
# branches: [dev]
64
workflow_dispatch:
75

86
jobs:
97
release:
108
name: Release to github and artifact
119
runs-on: ubuntu-latest
12-
env:
13-
CI: false
14-
appname: library
1510
steps:
16-
- uses: actions/checkout@v3
11+
- uses: actions/checkout@v4
1712
name: Check out code
1813

19-
- name: Create Zip Archive for artifact
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.11'
18+
19+
- name: Install Python dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install requests
23+
24+
- name: Fetch catalog inputs
25+
env:
26+
CONTENTFUL_GRAPHQL_TOKEN: ${{ secrets.CONTENTFUL_GRAPHQLTOKEN }}
2027
run: |
21-
mkdir ${{ env.appname }} artifacts
22-
cp -r apps ${{ env.appname }}
23-
cp -r docs ${{ env.appname }}
24-
cp -r template ${{ env.appname }}
25-
cp *.md ${{ env.appname }}
26-
cp ${{ env.appname }}.json ${{ env.appname }}
27-
zip -r ${{ env.appname }}-dev.zip ${{ env.appname }}
28-
cp ${{ env.appname }}-dev.zip artifacts
29-
30-
# - name: Upload library-dev.zip to artifacts
31-
# uses: actions/upload-artifact@v4
32-
# with:
33-
# name: ${{ env.appname }}-dev
34-
# path: ${{ env.appname }}
35-
36-
- name: Upload To cloudflare r2
28+
python build/fetch_catalog.py \
29+
--channel dev \
30+
--output-dir dist/catalog-source
31+
32+
- name: Build legacy and v2 artifacts
33+
run: |
34+
python build/library_publish.py \
35+
--channel dev \
36+
--output-dir dist/publish \
37+
--catalog-source-dir dist/catalog-source
38+
39+
- name: Upload workflow artifact
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: publish-dev
43+
path: dist/publish
44+
45+
- name: Upload legacy library to Cloudflare R2
3746
uses: ryand56/r2-upload-action@latest
3847
with:
3948
r2-account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
4049
r2-access-key-id: ${{ secrets.CLOUDFLARE_R2_SECRET_ID }}
4150
r2-secret-access-key: ${{ secrets.CLOUDFLARE_R2_SECRET_KEY }}
4251
r2-bucket: artifact
43-
source-dir: artifacts
52+
source-dir: dist/publish/legacy/dev/library
4453
destination-dir: ./dev/websoft9/plugin/library
4554

55+
- name: Upload legacy media to Cloudflare R2
56+
uses: ryand56/r2-upload-action@latest
57+
with:
58+
r2-account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
59+
r2-access-key-id: ${{ secrets.CLOUDFLARE_R2_SECRET_ID }}
60+
r2-secret-access-key: ${{ secrets.CLOUDFLARE_R2_SECRET_KEY }}
61+
r2-bucket: artifact
62+
source-dir: dist/publish/legacy/dev/media
63+
destination-dir: ./dev/websoft9/plugin/media
64+
4665
- name: Purge Cloudflare Cache
4766
uses: jakejarvis/cloudflare-purge-action@master
4867
env:
4968
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE_ID }}
5069
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
51-
PURGE_URLS: '["https://artifact.websoft9.com/dev/websoft9/plugin/library/library-dev.zip"]'
52-
53-
- name: Trigger websoft9/media-dev.yml workflow
54-
uses: benc-uk/workflow-dispatch@v1
55-
with:
56-
workflow: media_dev.yml
57-
repo: websoft9/websoft9
58-
ref: dev
59-
token: ${{secrets.MYGITHUB_ADMIN_TOKEN}}
70+
PURGE_URLS: '["https://artifact.websoft9.com/dev/websoft9/plugin/library/library-dev.zip","https://artifact.websoft9.com/dev/websoft9/plugin/media/media-dev.zip"]'

.github/workflows/release.yml

Lines changed: 74 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,90 +2,117 @@ name: Release to Github and artifact
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
library_version:
7+
description: Optional legacy release version tag used for the versioned library zip and GitHub Release
8+
required: false
9+
type: string
10+
from_ref:
11+
description: Optional git ref used to calculate apps-delta
12+
required: false
13+
type: string
514
repository_dispatch:
615
types: [custom_event]
716

817
jobs:
918
release:
1019
name: Release to github and artifact
1120
runs-on: ubuntu-latest
12-
env:
13-
CI: false
14-
appname: library
1521
steps:
16-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
1723
name: Check out code
1824

19-
- name: Version convert
20-
id: convert_version
25+
- name: Resolve release inputs
26+
id: resolve_inputs
2127
run: |
22-
curl https://raw.githubusercontent.com/Websoft9/websoft9/main/docker/apphub/Dockerfile -o Dockerfile
23-
24-
library_tag=$(grep 'ARG LIBRARY_VERSION' "Dockerfile" | cut -d'"' -f2 | xargs)
25-
apphub_tag=$(grep 'LABEL version' "Dockerfile" | cut -d'"' -f2 | xargs)
26-
27-
if [[ "$apphub_tag" == *"-"* ]]; then
28-
suffix="${apphub_tag#*-}"
29-
library_tag_gh="${library_tag}-${suffix}"
30-
echo "CHANNEL=dev" >> $GITHUB_ENV
31-
else
32-
library_tag_gh=$library_tag
33-
echo "CHANNEL=release" >> $GITHUB_ENV
28+
version="${{ inputs.library_version }}"
29+
if [[ -z "$version" ]]; then
30+
version="${{ github.event.client_payload.library_version }}"
31+
fi
32+
if [[ -z "$version" ]]; then
33+
version="$(date -u +%Y.%m.%d.%H%M%S)"
3434
fi
35+
from_ref="${{ inputs.from_ref }}"
36+
if [[ -z "$from_ref" ]]; then
37+
from_ref="${{ github.event.client_payload.from_ref }}"
38+
fi
39+
echo "library_version=$version" >> "$GITHUB_OUTPUT"
40+
echo "from_ref=$from_ref" >> "$GITHUB_OUTPUT"
41+
42+
- name: Set up Python
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: '3.11'
3546

36-
echo "LIBRARY_TAG=$library_tag" >> $GITHUB_ENV
37-
echo "LIBRARY_TAG_GH=$library_tag_gh" >> $GITHUB_ENV
47+
- name: Install Python dependencies
48+
run: |
49+
python -m pip install --upgrade pip
50+
pip install requests
3851
39-
jq --arg version "$library_tag_gh" '.Version = $version' library.json > temp.json && mv temp.json library.json
52+
- name: Fetch catalog inputs
53+
env:
54+
CONTENTFUL_GRAPHQL_TOKEN: ${{ secrets.CONTENTFUL_GRAPHQLTOKEN }}
55+
run: |
56+
python build/fetch_catalog.py \
57+
--channel release \
58+
--output-dir dist/catalog-source
4059
41-
- name: Create Zip Archive for artifact
60+
- name: Build legacy and v2 artifacts
4261
run: |
43-
mkdir ${{ env.appname }} artifacts
44-
cp -r apps ${{ env.appname }}
45-
cp -r docs ${{ env.appname }}
46-
cp -r template ${{ env.appname }}
47-
cp *.md ${{ env.appname }}
48-
cp ${{ env.appname }}.json ${{ env.appname }}
49-
cp ${{ env.appname }}.json CHANGELOG.md artifacts
50-
zip -r ${{ env.appname }}-${{ env.LIBRARY_TAG }}.zip ${{ env.appname }}
51-
cp ${{ env.appname }}-${{ env.LIBRARY_TAG }}.zip artifacts
52-
cp artifacts/${{ env.appname }}-${{ env.LIBRARY_TAG }}.zip artifacts/${{ env.appname }}-latest.zip
62+
args=(
63+
--channel release
64+
--output-dir dist/publish
65+
--catalog-source-dir dist/catalog-source
66+
--library-version "${{ steps.resolve_inputs.outputs.library_version }}"
67+
)
68+
if [[ -n "${{ steps.resolve_inputs.outputs.from_ref }}" ]]; then
69+
args+=(--from-ref "${{ steps.resolve_inputs.outputs.from_ref }}")
70+
fi
71+
python build/library_publish.py "${args[@]}"
5372
54-
- name: Upload To cloudflare r2
73+
- name: Upload workflow artifact
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: publish-release
77+
path: dist/publish
78+
79+
- name: Upload legacy library to Cloudflare R2
80+
uses: ryand56/r2-upload-action@latest
81+
with:
82+
r2-account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
83+
r2-access-key-id: ${{ secrets.CLOUDFLARE_R2_SECRET_ID }}
84+
r2-secret-access-key: ${{ secrets.CLOUDFLARE_R2_SECRET_KEY }}
85+
r2-bucket: artifact
86+
source-dir: dist/publish/legacy/release/library
87+
destination-dir: ./release/websoft9/plugin/library
88+
89+
- name: Upload legacy media to Cloudflare R2
5590
uses: ryand56/r2-upload-action@latest
5691
with:
5792
r2-account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
5893
r2-access-key-id: ${{ secrets.CLOUDFLARE_R2_SECRET_ID }}
5994
r2-secret-access-key: ${{ secrets.CLOUDFLARE_R2_SECRET_KEY }}
6095
r2-bucket: artifact
61-
source-dir: artifacts
62-
destination-dir: ./${{ env.CHANNEL }}/websoft9/plugin/${{ env.appname }}
96+
source-dir: dist/publish/legacy/release/media
97+
destination-dir: ./release/websoft9/plugin/media
6398

6499
- name: Purge Cloudflare Cache
65100
uses: jakejarvis/cloudflare-purge-action@master
66101
env:
67102
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE_ID }}
68103
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
69-
PURGE_URLS: '["https://artifact.websoft9.com/${{ env.CHANNEL }}/websoft9/plugin/library/library-latest.zip"]'
104+
PURGE_URLS: '["https://artifact.websoft9.com/release/websoft9/plugin/library/library-latest.zip","https://artifact.websoft9.com/release/websoft9/plugin/media/media.zip"]'
70105

71106
- name: Create Github Release from code
72107
uses: softprops/action-gh-release@v1
73108
with:
74109
files: |
75-
${{ env.appname }}.json
76-
tag_name: ${{ env.LIBRARY_TAG_GH }}
77-
name: ${{ env.LIBRARY_TAG_GH }}
110+
dist/publish/legacy/release/library/library.json
111+
tag_name: ${{ steps.resolve_inputs.outputs.library_version }}
112+
name: ${{ steps.resolve_inputs.outputs.library_version }}
78113
draft: false
79114
prerelease: false
80115

81-
- name: Trigger websoft9/json2md.yml workflow
82-
uses: benc-uk/workflow-dispatch@v1
83-
with:
84-
workflow: json2md.yml
85-
repo: websoft9/doc.websoft9.com
86-
ref: dev
87-
token: ${{secrets.MYGITHUB_ADMIN_TOKEN}}
88-
89116
pages:
90117
name: Build Github Pages
91118
permissions:

0 commit comments

Comments
 (0)