Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: multiarch snap release #114

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 18 additions & 69 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,74 +19,23 @@ concurrency:
jobs:
build:
name: Build snap
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: canonical/data-platform-workflows/.github/workflows/[email protected]

- name: Build snap locally
uses: snapcore/action-build@v1
id: build

- name: Get snapcraft track
if: ${{ github.ref_protected }}
id: track
run: |
if [ "${{ github.ref_name }}" == "master" ]; then
echo "::set-output name=track::latest"
elif [[ "${{ github.ref_name }}" =~ ^stable\/(.+) ]]; then
TRACK_NAME=${BASH_REMATCH[1]}
echo "::set-output name=track::$TRACK_NAME"
else
echo "Branch name does not match expected patterns. Exiting."
exit 1
fi

- name: Upload snap artifact
id: upload-snap
uses: actions/upload-artifact@v4
with:
name: snap
path: ${{ steps.build.outputs.snap }}

- name: publish snap
if: ${{ github.ref_protected }}
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
with:
snap: ${{ steps.build.outputs.snap }}
release: ${{ steps.track.outputs.track }}/edge

test-service:
name: Test snap service
test:
name: Test Vaultd service
needs: build
runs-on: ubuntu-latest
steps:
- name: Download snap artifact
uses: actions/download-artifact@v4
with:
name: snap

- name: Install snap
run: |
SNAP_NAME=$(ls *.snap)
echo "Installing snap $SNAP_NAME"
sudo snap install --dangerous $SNAP_NAME

- name: Start the vault snap service
run: |
sudo snap start vault
sleep 30

- name: Test snap service
run: |
sudo apt-get update
sudo apt-get install -y net-tools
# Check if a service is listening on port 8200
if netstat -tuln | grep ':8200'; then
echo "Service is listening on port 8200"
else
echo "Service is NOT listening on port 8200"
exit 1
fi
uses: ./.github/workflows/test-service.yaml

release:
if: ${{ github.ref_protected }}
name: Release snap
needs:
- build
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
with:
channel: 1.17/edge
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
secrets:
snap-store-token: ${{ secrets.SNAP_STORE_TOKEN }}
permissions:
contents: write # Needed to create GitHub release
42 changes: 42 additions & 0 deletions .github/workflows/test-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
workflow_call:

jobs:
test-service:
strategy:
matrix:
base:
- arch: amd64
runner: ubuntu-22.04
- arch: arm64
runner: Ubuntu_ARM64_4C_16G_02
name: 'Build snap | ${{ matrix.base.id }}'
runs-on: ${{ matrix.base.runner }}
steps:
- name: Download snap artifact
uses: actions/download-artifact@v4
with:
name: ${{needs.build.outputs.artifact-prefix}}-architecture-${{ matrix.base.arch }}

- name: Install snap
run: |
SNAP_NAME=$(ls *.snap)
echo "Installing snap $SNAP_NAME"
sudo snap install --dangerous $SNAP_NAME

- name: Start the vault snap service
run: |
sudo snap start vault
sleep 30

- name: Test snap service
run: |
sudo apt-get update
sudo apt-get install -y net-tools
# Check if a service is listening on port 8200
if netstat -tuln | grep ':8200'; then
echo "Service is listening on port 8200"
else
echo "Service is NOT listening on port 8200"
exit 1
fi
6 changes: 0 additions & 6 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ architectures:
build-for: [amd64]
- build-on: [arm64]
build-for: [arm64]
- build-on: [armhf]
build-for: [armhf]
- build-on: [ppc64el]
build-for: [ppc64el]
- build-on: [s390x]
build-for: [s390x]


package-repositories:
Expand Down
Loading