chore(deps): update dependency canonical/snapcraft to v8.2.7 (#43) #112
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, test and publish rock | |
on: | |
pull_request: | |
branches: | |
- 'core2[24]-[78]' | |
push: | |
branches: | |
- 'core2[24]-[78]' | |
jobs: | |
build-rock: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Build rock | |
uses: canonical/craft-actions/rockcraft-pack@main | |
- name: Get rock name | |
id: vars | |
run: | | |
if [[ "${{ github.event_name }}" == "pull_request" ]] | |
then | |
echo "rockname=pr-${{ github.event.number }}" >> "$GITHUB_OUTPUT" | |
else | |
echo "rockname=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Upload rock | |
# NOTE: using v3 (for this and other actions) due to node versions | |
# on self-hosted runners (no node20) | |
uses: actions/upload-artifact@v3 | |
with: | |
name: snapcraft-rock | |
path: '*.rock' | |
spread-tests: | |
runs-on: self-hosted | |
needs: [build-rock] | |
steps: | |
- name: Cleanup job workspace | |
run: | | |
rm -rf "${{ github.workspace }}" | |
mkdir "${{ github.workspace }}" | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
submodules: true | |
- name: Download rock artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: snapcraft-rock | |
path: tests | |
- name: Run spread | |
run: spread | |
publish-rock: | |
runs-on: ubuntu-22.04 | |
needs: [build-rock] | |
# Not on pull requests; only when they're merged | |
if: github.event_name == 'push' | |
permissions: | |
packages: write | |
steps: | |
- name: Download rock artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: snapcraft-rock | |
- name: Install rockcraft | |
run: sudo snap install --classic rockcraft | |
- name: Publish rock to Github Container Registry | |
run: | | |
# Split the base branch name ("core22-7") into core ("core22") and version ("7") | |
array_ref=(${GITHUB_REF_NAME//-/ }) | |
snapcraft_core=${array_ref[0]} | |
snapcraft_version=${array_ref[1]} | |
source_rock="oci-archive:$(ls snapcraft*.rock)" | |
target_image="ghcr.io/canonical/snapcraft:${snapcraft_version}_${snapcraft_core}" | |
dest_image="docker://${target_image}" | |
/snap/rockcraft/current/bin/skopeo --insecure-policy copy ${source_rock} ${dest_image} --dest-creds "${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }}" | |
echo "Image is available at ${target_image}" |