Skip to content

Commit

Permalink
Add CI/CD pipeline to publish on charmhub.io (#95)
Browse files Browse the repository at this point in the history
* Add CI/CD pipeline to publish on charmhub.io

* generated and configured new CHARMHUB_TOKEN

* Do not call ci.yaml on merge to trunk

The release.yaml will run ci.yaml tests after merging and before publishing.
  • Loading branch information
taurus-forever authored Jan 24, 2023
1 parent 2f3c832 commit 784c51f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Charmed Operator Tests
on:
workflow_call:
push:
branches:
- main
pull_request:

jobs:
Expand All @@ -12,4 +9,4 @@ jobs:
unit:
uses: ./.github/workflows/unit.yaml
integration:
uses: ./.github/workflows/integration.yaml
uses: ./.github/workflows/integration.yaml
49 changes: 49 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release to latest/edge

on:
push:
branches:
- main

jobs:
lib-check:
name: Check libraries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check libs
uses: canonical/charming-actions/[email protected]
with:
# FIXME: CHARMHUB_TOKEN will expire in 2024-01-20
# NOTE: CHARMHUB_TOKEN is only allowed in latest/edge, latest/candidate
credentials: "${{ secrets.CHARMHUB_TOKEN }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"

ci-tests:
needs:
- lib-check
uses: ./.github/workflows/ci.yaml

release-to-charmhub:
name: Release to CharmHub
needs:
- lib-check
- ci-tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Select charmhub channel
uses: canonical/charming-actions/[email protected]
id: channel
- name: Upload charm to charmhub
uses: canonical/charming-actions/[email protected]
with:
credentials: "${{ secrets.CHARMHUB_TOKEN }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"
channel: "${{ steps.channel.outputs.name }}"

0 comments on commit 784c51f

Please sign in to comment.