Skip to content

Commit 6fbe20b

Browse files
authored
Add publish workflow (#15)
* Added publish workflow * Updated preparation command in README
1 parent f295bf3 commit 6fbe20b

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed

.github/workflows/publish.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Publish to edge
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
publish-charm:
11+
name: Publish charm and rock
12+
strategy:
13+
fail-fast: false
14+
max-parallel: 1
15+
matrix:
16+
arch: [amd64, arm64]
17+
runs-on: [self-hosted, linux, "${{ matrix.arch }}"]
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: setup lxd
21+
uses: canonical/setup-lxd@v0.1.2
22+
- name: prepare application source
23+
run: |
24+
cp dashboard_rock_patch/dashboard/settings.py dashboard/dashboard
25+
- name: build rock
26+
run: |
27+
set -x
28+
sudo snap install --channel latest/stable --classic rockcraft
29+
rockcraft pack --verbosity trace
30+
docker run -d -p 5000:5000 --name registry registry:latest
31+
rockcraft.skopeo --insecure-policy copy --dest-tls-verify=false oci-archive:$(ls *.rock) docker://localhost:5000/dashboard:latest
32+
- name: upload rock
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: rock-${{ matrix.arch }}
36+
path: "*.rock"
37+
- run: |
38+
docker pull localhost:5000/dashboard:latest
39+
- name: build charm
40+
id: charmcraft
41+
working-directory: charm
42+
run: |
43+
set -x
44+
sudo snap install --channel latest/stable --classic charmcraft
45+
charmcraft pack --verbosity trace
46+
echo charms=`ls *.charm` >> $GITHUB_OUTPUT
47+
- name: upload charm
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: charm-${{ matrix.arch }}
51+
path: ./charm/${{ steps.charmcraft.outputs.charms }}
52+
- run: |
53+
sudo apt update && sudo apt install python3-yaml -y
54+
- name: expand charmcraft.yaml
55+
working-directory: charm
56+
run: |
57+
charmcraft expand-extensions > ../charmcraft.yaml
58+
- name: update upstream-source
59+
shell: python
60+
run: |
61+
import yaml
62+
63+
charmcraft_yaml = yaml.safe_load(open("charmcraft.yaml"))
64+
resources = charmcraft_yaml["resources"]
65+
resources[list(resources)[0]]["upstream-source"] = "localhost:5000/dashboard:latest"
66+
yaml.dump(charmcraft_yaml, open("charmcraft.yaml", "w"), sort_keys=False)
67+
- name: show charmcraft.yaml
68+
run: |
69+
cat charmcraft.yaml
70+
- if: github.event_name == 'push'
71+
name: publish charm
72+
uses: canonical/charming-actions/upload-charm@2.7.0
73+
with:
74+
credentials: ${{ secrets.CHARMHUB_TOKEN }}
75+
github-token: ${{ secrets.GITHUB_TOKEN }}
76+
built-charm-path: ./charm/${{ steps.charmcraft.outputs.charms }}
77+
tag-prefix: ${{ matrix.arch }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Work in progress. Aspects to cover:
2121
- Set up Juju and craft tools, pack rock, pack charm, deploy charm.
2222
Before packing the rock, run:
2323
```
24-
cp dashboard_rock_patch/dashboard/settings.py dashboard/dashboard/settings.py
24+
cp dashboard_rock_patch/dashboard/settings.py dashboard/dashboard
2525
```
2626
- Integrate the PostgreSQL charm
2727
- Configure charm to work without ingress, in debug mode

0 commit comments

Comments
 (0)