Skip to content

Commit

Permalink
feat: update release action
Browse files Browse the repository at this point in the history
  • Loading branch information
junkurihara committed Nov 2, 2023
1 parent 5e1727f commit dae76aa
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 63 deletions.
19 changes: 13 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,30 @@ version: 2
updates:
# Enable version updates for cargo
- package-ecosystem: "cargo"
# Look for `Cargo.toml` and `lock` files in the `root` directory
directory: "/"
# Check the crates.io for updates every day (weekdays)
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/dap-bin"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/dap-lib"
schedule:
interval: "daily"
- package-ecosystem: "cargo"
directory: "/legacy"
schedule:
interval: "daily"

# Enable version updates for Docker
- package-ecosystem: "docker"
# Look for a `Dockerfile` in the `root` directory
directory: "/"
# Check for updates everyday
directory: "/docker"
schedule:
interval: "daily"

# Enable version updates for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates everyday
interval: "daily"
49 changes: 0 additions & 49 deletions .github/workflows/docker_build_push.yml

This file was deleted.

113 changes: 113 additions & 0 deletions .github/workflows/release-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Nightly and release build

on:
push:
branches:
- "develop"
pull_request:
types: [closed]
branches:
- main

env:
GHCR: ghcr.io
GHCR_IMAGE_NAME: ${{ github.repository }}
DH_REGISTRY_NAME: jqtype/doh-auth-proxy

jobs:
docker_build_and_push:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }} || ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }}
strategy:
fail-fast: false

steps:
- name: checkout
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}

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

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GHCR }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Release Build and push x86_64
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref == 'develop' && github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true }}
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}:latest
${{ env.DH_REGISTRY_NAME }}:latest
file: ./docker/Dockerfile
cache-from: type=gha,scope=doh-auth-proxy-latest
cache-to: type=gha,mode=max,scope=doh-auth-proxy-latest
labels: ${{ steps.meta.outputs.labels }}

- name: Nightly build and push x86_64
if: ${{ (github.ref_name == 'develop') && (github.event_name == 'push') }}
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}:nightly
${{ env.DH_REGISTRY_NAME }}:nightly
file: ./docker/Dockerfile
cache-from: type=gha,scope=doh-auth-proxy-nightly
cache-to: type=gha,mode=max,scope=doh-auth-proxy-nightly
labels: ${{ steps.meta.outputs.labels }}

dispatch_release:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref == 'develop' && github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true }}
needs: docker_build_and_push
steps:
- name: check pull_request title
uses: kaisugi/[email protected]
id: regex-match
with:
text: ${{ github.event.pull_request.title }}
regex: "^(\\d+\\.\\d+\\.\\d+)$"

- name: checkout
if: ${{ steps.regex-match.outputs.match != '' }}
uses: actions/checkout@v4

- name: build release binary
if: ${{ steps.regex-match.outputs.match != '' }}
id: "build"
run: |
cargo build --release --package doh-auth-proxy
cp ./target/release/doh-auth-proxy /tmp/doh-auth-proxy
cd /tmp
tar zcvf doh-auth-proxy-x86_64-unknown-linux-gnu.tar.gz doh-auth-proxy
- name: release
if: ${{ steps.regex-match.outputs.match != ''}}
uses: softprops/action-gh-release@v1
with:
files: /tmp/assets/*.tar.gz
name: ${{ github.event.pull_request.title }}
tag_name: ${{ github.event.pull_request.title }}
body: ${{ github.event.pull_request.body }}
draft: true
prerelease: false
generate_release_notes: true
15 changes: 7 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
name: Unit test for some mods in doh-auth-proxy
name: Unit tests

on:
push:
branches: [ main, develop ]
branches: [main, develop]
pull_request:
branches: [ main, develop ]
branches: [main, develop]

env:
CARGO_TERM_COLOR: always

jobs:
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Run unit tests
run: |
cargo test --verbose
- uses: actions/checkout@v4
- name: Run unit tests
run: |
cargo test --verbose

0 comments on commit dae76aa

Please sign in to comment.