Skip to content

Commit

Permalink
Merge pull request #38 from canonical/add-charming-actions
Browse files Browse the repository at this point in the history
Update publish and add release action
  • Loading branch information
DomFleischmann authored Jun 1, 2022
2 parents 1588f0c + 70b7b2c commit 7349e21
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 65 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/get-charm-paths.sh

This file was deleted.

24 changes: 20 additions & 4 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
# reusable workflow triggered by other actions
name: CI

on:
push:
branches:
- master
pull_request:
workflow_call:
secrets:
charmcraft-credentials:
required: true

jobs:

lib-check:
name: Check libraries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check libs
uses: canonical/charming-actions/[email protected]
with:
credentials: "${{ secrets.charmcraft-credentials }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"

lint:
name: Lint
runs-on: ubuntu-latest
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/on_pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test and publish to branch

# On pull_request, we:
# * always publish to charmhub at latest/edge/branchname
# * always run tests

on:
pull_request:

jobs:

tests:
name: Run Tests
uses: ./.github/workflows/integration.yaml
secrets:
charmcraft-credentials: "${{ secrets.CHARMCRAFT_CREDENTIALS }}"

# publish runs in parallel with tests, as we always publish in this situation
publish-charm:
name: Publish Charm
uses: ./.github/workflows/publish.yaml
secrets:
charmcraft-credentials: "${{ secrets.CHARMCRAFT_CREDENTIALS }}"
31 changes: 31 additions & 0 deletions .github/workflows/on_push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish to edge if tests passed

# On push to a "special" branch, we:
# * always publish to charmhub at latest/edge/branchname
# * always run tests
# where a "special" branch is one of main/master or track/**, as
# by convention these branches are the source for a corresponding
# charmhub edge channel.

on:
push:
branches:
- master
- main
- track/**

jobs:

tests:
name: Run Tests
uses: ./.github/workflows/integration.yaml
secrets:
charmcraft-credentials: "${{ secrets.CHARMCRAFT_CREDENTIALS }}"

# publish runs in series with tests, and only publishes if tests passes
publish-charm:
name: Publish Charm
needs: tests
uses: ./.github/workflows/publish.yaml
secrets:
charmcraft-credentials: "${{ secrets.CHARMCRAFT_CREDENTIALS }}"
54 changes: 25 additions & 29 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
# reusable workflow triggered by other actions
name: Publish

on:
push:
branches:
- master
- main
- track/**
pull_request:
branches:
- master
- main
- track/**
workflow_call:
secrets:
charmcraft-credentials:
required: true

jobs:
get-charm-matrix:
name: Generate the Charm Matrix
runs-on: ubuntu-latest
outputs:
charm_paths_json: ${{ steps.get-charm-matrix-step.outputs.CHARM_PATHS_JSON }}
steps:
- uses: actions/checkout@v2
- name: Get paths for all charms in repo
id: get-charm-matrix-step
run: bash ./.github/workflows/get-charm-paths.sh

publish-charm:
name: Publish Charm
runs-on: ubuntu-latest
# Only publish to charmhub if we are pushing to a special branch or running PRs from something named `branch/*`
if: (github.event_name == 'push') || (startsWith( github.head_ref, 'branch/' ))
needs: get-charm-matrix
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.get-charm-matrix.outputs.charm_paths_json) }}
matrix:
charm:
- mlflow-server
steps:
- uses: actions/checkout@v2
- uses: canonical/[email protected]
- name: Checkout
uses: actions/checkout@v2
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.CHARMCRAFT_CREDENTIALS }}
charm-path: ${{ matrix.charm-path }}
charmcraft-channel: latest/edge
credentials: ${{ secrets.charmcraft-credentials }}
github-token: ${{ secrets.GITHUB_TOKEN }}
charm-path: charms/${{ matrix.charm }}
channel: ${{ steps.channel.outputs.name }}
tag-prefix: ${{ matrix.charm }}
31 changes: 31 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# reusable workflow triggered manually
name: Release charm to other tracks and channels

on:
workflow_dispatch:
inputs:
destination-channel:
description: 'Destination Channel'
required: true
origin-channel:
description: 'Origin Channel'
required: true
charm-name:
description: 'Charm subdirectory name'
required: true

jobs:
promote-charm:
name: Promote charm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Release charm to channel
uses: canonical/charming-actions/[email protected]
with:
credentials: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
destination-channel: ${{ github.event.inputs.destination-channel }}
origin-channel: ${{ github.event.inputs.origin-channel }}
tag-prefix: ${{ github.event.inputs.charm-name }}
charm-path: charms/${{ github.event.inputs.charm-name}}
3 changes: 2 additions & 1 deletion charms/mlflow-server/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ bases:
channel: '20.04'
parts:
charm:
charm-python-packages: [setuptools, pip]
# do not use these versions due to pypa/setuptools_scm#713
charm-python-packages: [setuptools!=62.2.0, pip!=22.1]

0 comments on commit 7349e21

Please sign in to comment.