|
| 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 }} |
0 commit comments