diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 4b3d37678..2d00cff53 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -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/build_snap.yaml@v22.0.0 - - 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/release_snap.yaml@v22.0.0 + 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 diff --git a/.github/workflows/test-service.yaml b/.github/workflows/test-service.yaml new file mode 100644 index 000000000..fedda7346 --- /dev/null +++ b/.github/workflows/test-service.yaml @@ -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 \ No newline at end of file diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 8e712dd06..d6f07e76f 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -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: