Skip to content

chore: upgrade installe #78

chore: upgrade installe

chore: upgrade installe #78

name: Publish Stable Image
on:
push:
branches:
- "release/stable/bin/**"
pull_request:
branches:
- "release/stable/bin/**"
types: [opened, synchronize]
env:
CARGO_TERM_COLOR: always
jobs:
release_image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Install buildx
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
# Set buildx cache
- name: Cache register
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: buildx-cache
# Login to ghcr.io
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.BOT_USERNAME }}
password: ${{ secrets.BOT_TOKEN }}
# Extract branch info
- name: Set info
run: |
echo "CHANNEL=$(echo ${GITHUB_REF} | awk -F/ '{print $4}')" >> $GITHUB_ENV
echo "NANOCL_CHANNEL=$(echo ${GITHUB_REF} | awk -F/ '{print $4}')" >> $GITHUB_ENV
echo "BINARY_NAME=$(echo ${GITHUB_REF} | awk -F/ '{print $6}')" >> $GITHUB_ENV
echo "VERSION=$(echo ${GITHUB_REF} | awk -F/ '{print $7}')" >> $GITHUB_ENV
# Print info for debug
- name: Print Info
run: |
echo $BRANCH_NAME
echo $BINARY_NAME
echo $CHANNEL
echo $VERSION
# Create buildx multiarch
- name: Create buildx multiarch
run: docker buildx create --use --name=buildx-multi-arch --driver=docker-container --driver-opt=network=host
# Build daemon image
# Build daemon image
- name: Build image
run: docker buildx build --builder=buildx-multi-arch --platform=linux/amd64,linux/arm/v7,linux/arm64 --build-arg channel=$CHANNEL --push --label org.opencontainers.image.source=https://github.com/next-hat/nanocl -t ghcr.io/next-hat/$BINARY_NAME:$VERSION -t ghcr.io/next-hat/$BINARY_NAME:latest -f ./bin/$BINARY_NAME/Dockerfile .
# Export it as tar.gz
# - name: Export image
# run: docker save ghcr.io/next-hat/$BINARY_NAME:$VERSION | gzip > /tmp/$BINARY_NAME-$VERSION.tar.gz
# Upload it to release
- name: Test if release already exists
id: release-exists
continue-on-error: true
run: gh release view $BINARY_NAME-$VERSION
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
- name: Create new draft release
if: steps.release-exists.outcome == 'failure' && steps.release-exists.conclusion == 'success'
run: gh release create -t $BINARY_NAME-$VERSION -d $BINARY_NAME-$VERSION -F ./bin/$BINARY_NAME/changelog.md;
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
# - name: Update draft release
# if: steps.release-exists.outcome == 'success' && steps.release-exists.conclusion == 'success'
# run: |
# gh release delete-asset -y $BINARY_NAME-$VERSION $BINARY_NAME-$VERSION.tar.gz || true
# gh release upload $BINARY_NAME-$VERSION /tmp/$BINARY_NAME-$VERSION.tar.gz#$BINARY_NAME-image
# env:
# GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}