Skip to content

Commit

Permalink
Use strategy matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
sed-i committed Nov 19, 2024
1 parent 4965e85 commit e05289f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 42 deletions.
59 changes: 17 additions & 42 deletions .github/workflows/release-snap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,18 @@ env:
LAUNCHPAD_TOKEN: ${{ secrets.LAUNCHPAD_TOKEN }}

jobs:
build-strict:
build:
name: Build snap (strict)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# snapcraft remote-build requires a full clone
fetch-depth: 0

- name: Setup LXD
uses: canonical/[email protected]
with:
channel: latest/stable

- name: Install dependencies
run: |
sudo snap install --classic --channel edge snapcraft
# Setup Launchpad credentials
mkdir -p ~/.local/share/snapcraft
echo -e "$LAUNCHPAD_TOKEN" >> ~/.local/share/snapcraft/launchpad-credentials
mkdir -p ~/.local/share/snapcraft/provider/launchpad
echo -e "$LAUNCHPAD_TOKEN" >> ~/.local/share/snapcraft/provider/launchpad/credentials
git config --global user.email "[email protected]"
git config --global user.name "Github Actions"
- name: Build Snap (remote)
run: snapcraft remote-build --launchpad-accept-public-upload

- name: Upload and Publish amd64 Snap
run: snapcraft upload --release edge grafana-agent_*_amd64.snap

- name: Upload and Publish arm64 Snap
run: snapcraft upload --release edge grafana-agent_*_arm64.snap

build-classic:
name: Build snap (classic)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
confinement: [ "strict", "classic" ]
include:
- confinement: "strict"
channel: "latest/edge"
- confinement: "classic"
channel: "0.40-classic/edge"
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -79,14 +53,15 @@ jobs:
- name: yq - portable yaml processor
uses: mikefarah/yq@v4

- name: Convert to Classic Snap
- if: ${{ matrix.confinement == 'classic' }}
name: Convert to Classic Snap
run: ./make-classic.sh

- name: Build Classic Snap (remote)
- name: Build Snap (remote)
run: snapcraft remote-build --launchpad-accept-public-upload

- name: Upload and Publish Classic amd64 Snap
run: snapcraft upload --release 0.40-classic/edge grafana-agent_*_amd64.snap
- name: Upload and Publish amd64 Snap
run: snapcraft upload --release ${{ matrix.channel }} grafana-agent_*_amd64.snap

- name: Upload and Publish Classic arm64 Snap
run: snapcraft upload --release 0.40-classic/edge grafana-agent_*_arm64.snap
- name: Upload and Publish arm64 Snap
run: snapcraft upload --release ${{ matrix.channel }} grafana-agent_*_arm64.snap
12 changes: 12 additions & 0 deletions .github/workflows/test-build-snap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ env:

jobs:
build:
name: Build snap (strict)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
confinement: [ "strict", "classic" ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -35,5 +40,12 @@ jobs:
git config --global user.email "[email protected]"
git config --global user.name "Github Actions"
- name: yq - portable yaml processor
uses: mikefarah/yq@v4

- if: ${{ matrix.confinement == 'classic' }}
name: Convert to Classic Snap
run: ./make-classic.sh

- name: Build Snap (remote)
run: snapcraft remote-build --launchpad-accept-public-upload

0 comments on commit e05289f

Please sign in to comment.