forked from jaoafa/VCSpeaker.kt
-
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.
Merge pull request #1 from book000/feat/improve-dockerfile
feat: Dockerパッケージ処理の改善
- Loading branch information
Showing
3 changed files
with
123 additions
and
34 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 |
---|---|---|
|
@@ -4,10 +4,16 @@ on: | |
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Release: | ||
bump-version: | ||
name: 🔼 Bump version | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
new_version: ${{ steps.version.outputs.new_version }} | ||
|
||
steps: | ||
- name: 🔼 Bump release version | ||
id: version | ||
|
@@ -16,57 +22,122 @@ jobs: | |
github_token: ${{ github.token }} | ||
default_bump: "minor" | ||
custom_release_rules: "breaking:major:💣 Breaking Changes,feat:minor:✨ Features,fix:patch:💣 Bug Fixes,docs:patch:📰 Docs,chore:patch:🎨 Chore,pref:patch:🎈 Performance improvements,refactor:patch:🧹 Refactoring,build:patch:🔍 Build,ci:patch:🔍 CI,revert:patch:⏪ Revert,style:patch:🧹 Style,test:patch:👀 Test" | ||
- name: "☕ Setup Zulu JDK17" | ||
|
||
build-docker: | ||
name: 🏗️ Build Docker (${{ matrix.architecture }}}) | ||
runs-on: ubuntu-latest | ||
needs: bump-version | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
architecture: [amd64, arm64] | ||
|
||
steps: | ||
- name: 📥 Checkout ${{ github.repository }} | ||
uses: actions/checkout@v3 | ||
|
||
- name: 🐋 Setup QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: 🏗️ Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: 📥 Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: 📝 Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/[email protected] | ||
with: | ||
images: ghcr.io/${{ github.repository }}:${{ matrix.architecture }} | ||
tags: | | ||
type=raw,value=${{ needs.bump-version.outputs.new_version }}-${{ matrix.architecture }} | ||
type=raw,value=latest-${{ matrix.architecture }} | ||
- name: 🚀 Build Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
platforms: linux/${{ matrix.architecture }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
merge-latest: | ||
name: 📥 Merge latest | ||
runs-on: ubuntu-latest | ||
needs: | ||
- bump-version | ||
- build-docker | ||
|
||
steps: | ||
- name: 📥 Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create and push manifest images (latest) | ||
uses: Noelware/[email protected] | ||
with: | ||
images: ghcr.io/${{ github.repository }}:latest | ||
inputs: ghcr.io/${{ github.repository }}:latest-amd64,ghcr.io/${{ github.repository }}:latest-arm64 | ||
push: true | ||
|
||
- name: Create and push manifest images (version) | ||
uses: Noelware/[email protected] | ||
with: | ||
images: ghcr.io/${{ github.repository }}:${{ needs.bump-version.outputs.new_version }} | ||
inputs: ghcr.io/${{ github.repository }}:${{ needs.bump-version.outputs.new_version }}-amd64,ghcr.io/${{ github.repository }}:${{ needs.bump-version.outputs.new_version }}-arm64 | ||
push: true | ||
|
||
create-release: | ||
name: 📦 Create Release | ||
runs-on: ubuntu-latest | ||
needs: | ||
- bump-version | ||
- build-docker | ||
- merge-latest | ||
|
||
steps: | ||
- name: ☕ Setup Zulu JDK 17 | ||
uses: actions/[email protected] | ||
with: | ||
distribution: "zulu" | ||
java-version: "17" | ||
distribution: zulu | ||
java-version: 17 | ||
|
||
- name: 🐘 Setup Gradle | ||
uses: gradle/gradle-build-action@v2 | ||
with: | ||
gradle-version: release-candidate | ||
|
||
- name: 📥 Checkout ${{ github.repository }} | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: ${{ github.repository }} | ||
token: ${{ github.token }} | ||
path: project | ||
|
||
- name: ⌛ Restore caches | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.gradle/caches | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }} | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: 🐘 Run Gradle command | ||
run: | | ||
cd project | ||
gradle build | ||
mv build/libs/*.jar build/libs/vcspeaker-kt.jar | ||
- name: 🗃️ Publish Release on main | ||
env: | ||
project_version: ${{ steps.version.outputs.new_version }} | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
generate_release_notes: true | ||
tag_name: ${{ env.project_version }} | ||
tag_name: ${{ needs.bump-version.outputs.new_version }} | ||
files: | | ||
project/build/libs/vcspeaker-kt.jar | ||
- name: 🏗️ Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: 📥 Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: 🚀 Build Docker image | ||
env: | ||
project_version: ${{ steps.version.outputs.new_version }} | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./project | ||
push: true | ||
tags: | | ||
ghcr.io/jaoafa/vcspeaker-kt:latest | ||
ghcr.io/jaoafa/vcspeaker-kt:${{ env.project_version }} |
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
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,6 @@ | ||
services: | ||
app: | ||
build: . | ||
volumes: | ||
- ./data:/data | ||
init: true |