Skip to content

Commit

Permalink
chore: update release ci
Browse files Browse the repository at this point in the history
Signed-off-by: Dup4 <[email protected]>
  • Loading branch information
Dup4 committed Nov 5, 2023
1 parent 09c59bb commit 0e452f8
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 70 deletions.
70 changes: 0 additions & 70 deletions .github/workflows/build.yml

This file was deleted.

99 changes: 99 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#
name: Release

on:
push:
tags:
- "v*"

jobs:
release-github-packages:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Release
run: npx changelogithub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release-docker-image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get Version ID
id: get-version-id
run: |
VERSION_ID=$(cat package.json | grep version | sed 's| \"version\": \"||g' | sed 's|\",||g')
echo "::set-output name=version-id::$(echo $VERSION_ID)"
echo $VERSION_ID
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-single-buildx
- name: Build and push
uses: docker/build-push-action@v5
env:
image_name: hznuoj
tag: ${{ steps.get-version-id.outputs.version-id }}
with:
context: .
file: ./docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
hznuoj/${{ env.image_name }}:latest
hznuoj/${{ env.image_name }}:${{ env.tag }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

0 comments on commit 0e452f8

Please sign in to comment.