-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Publish stable | ||
|
||
on: | ||
push: | ||
branches: | ||
- "release/stable/**" | ||
pull_request: | ||
branches: | ||
- "release/stable/**" | ||
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 "BINARY_NAME=$(echo ${GITHUB_REF} | awk -F/ '{print $5}')" >> $GITHUB_ENV | ||
# Print info for debug | ||
- name: Print Info | ||
run: | | ||
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 image | ||
- name: Build image | ||
run: | | ||
docker buildx build \ | ||
--builder=buildx-multi-arch \ | ||
--platform=linux/amd64,linux/arm/v7,linux/arm64 \ | ||
--label org.opencontainers.image.source=https://github.com/next-hat/metrs \ | ||
-t ghcr.io/next-hat/metrsd:$VERSION \ | ||
-t ghcr.io/next-hat/metrsd:latest \ | ||
-f ./Dockerfile . \ | ||
--push | ||
# Upload it to release | ||
- name: Test if release already exists | ||
id: release-exists | ||
continue-on-error: true | ||
run: gh release view $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 $VERSION -d $VERSION | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} |