Skip to content

Commit

Permalink
Merge pull request #104 from junkurihara/develop
Browse files Browse the repository at this point in the history
0.6.2
  • Loading branch information
junkurihara authored Oct 12, 2023
2 parents 9340679 + d247bd8 commit b1c87ec
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 20 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/docker_build_push.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Build and publish docker
name: Build and publish docker, and trigger release
on:
push:
branches:
- "develop"
- "main"
tags:
- "*.*.*"
pull_request:
types: [closed]
branches:
- main

env:
GHCR: ghcr.io
Expand All @@ -15,6 +16,7 @@ env:
jobs:
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
matrix:
Expand Down Expand Up @@ -167,3 +169,14 @@ jobs:
cache-to: type=gha,mode=max,scope=rpxy-latest-${{ matrix.target }}
platforms: ${{ matrix.platforms }}
labels: ${{ steps.meta.outputs.labels }}

dispatch_release_event:
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: build_and_push
steps:
- name: Repository dispatch for release
uses: peter-evans/repository-dispatch@v2
with:
event-type: release-event
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "pull_request": { "title": "${{ github.event.pull_request.title }}", "body": "${{ github.event.pull_request.body }}", "number": "${{ github.event.pull_request.number }}", "head": "${{ github.event.pull_request.head.ref }}", "base": "${{ github.event.pull_request.base.ref}}"}}'
49 changes: 34 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ on:
- "Build and publish docker"
types:
- "completed"
branches:
- main
- develop
repository_dispatch:
types:
- release-event

jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' }} || ${{ github.event_name == 'repositry_dispatch' }}
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -70,59 +76,72 @@ jobs:

steps:
- run: "echo 'The relese triggering workflows passed'"

- name: "set env"
id: "set-env"
run: |
if [ ${{ matrix.platform }} = "linux/amd64" ];then PLATFORM_MAP="x86_64";else PLATFORM_MAP="aarch64";fi
if [ ${{ github.ref_name == 'develop' }} ];then BUILD_NAME="rpxy-nightly";else BUILD_NAME="rpxy";fi
echo "PLATFORM_MAP=${PLATFORM_MAP}" >> $GITHUB_ENV
echo "TARGET_NAME=${BUILD_NAME}-${PLATFORM_MAP}-unknown-linux-${{ matrix.target }}${{ matrix.build-feature }}" >> $GITHUB_ENV
if [ ${{ matrix.platform }} == 'linux/amd64' ]; then PLATFORM_MAP="x86_64"; else PLATFORM_MAP="aarch64"; fi
if [ ${{ github.ref_name }} == 'develop' ]; then BUILD_NAME="-nightly"; else BUILD_NAME=""; fi
if [ ${{ github.ref_name }} == 'develop' ]; then BUILD_IMG="nightly"; else BUILD_IMG="latest"; fi
echo "build_img=${BUILD_IMG}" >> $GITHUB_OUTPUT
echo "target_name=rpxy${BUILD_NAME}-${PLATFORM_MAP}-unknown-linux-${{ matrix.target }}${{ matrix.build-feature }}" >> $GITHUB_OUTPUT
- name: "docker pull and extract binary from docker image"
id: "extract-binary"
run: |
CONTAINER_ID=`docker create --platform=${{ matrix.platform }} ghcr.io/junkurihara/rust-rpxy:nightly${{ matrix.tags-suffix }}`
docker cp ${CONTAINER_ID}:/rpxy/bin/rpxy /tmp/${TARGET_NAME}
cd /tmp
echo "artifact=${TARGET_NAME}" >> $GITHUB_OUTPUT
CONTAINER_ID=`docker create --platform=${{ matrix.platform }} ghcr.io/junkurihara/rust-rpxy:${{ steps.set-env.outputs.build_img }}${{ matrix.tags-suffix }}`
docker cp ${CONTAINER_ID}:/rpxy/bin/rpxy /tmp/${{ steps.set-env.outputs.target_name }}
- name: "upload artifacts"
uses: actions/upload-artifact@v3
with:
name: ${{ steps.extract-binary.outputs.artifact }}
path: "/tmp/${{ steps.extract-binary.outputs.artifact }}"
name: ${{ steps.set-env.outputs.target_name }}
path: "/tmp/${{ steps.set-env.outputs.target_name }}"

on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The release triggering workflows failed'

release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
if: ${{ github.event_name == 'repository_dispatch' }}
needs: on-success
steps:
- name: check pull_request title
uses: kaisugi/[email protected]
id: regex-match
with:
text: ${{ github.event.client_payload.pull_request.title }}
regex: "^(\\d+\\.\\d+\\.\\d+)$"

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

- name: download artifacts
if: ${{ steps.regex-match.outputs.match != ''}}
uses: actions/download-artifact@v3
with:
path: /tmp/rpxy

- name: make tar.gz of assets
if: ${{ steps.regex-match.outputs.match != ''}}
run: |
mkdir /tmp/assets
cd /tmp/rpxy
for i in ./*; do sh -c "cd $i && tar zcvf $i.tar.gz $i && mv $i.tar.gz /tmp/assets/"; done
ls -lha /tmp/assets
- name: release
if: ${{ steps.regex-match.outputs.match != ''}}
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: /tmp/assets/*.tar.gz
tag_name: ${{ github.ref }}
name: ${{ github.event.client_payload.pull_request.title }}
tag_name: ${{ github.event.client_payload.pull_request.title }}
body: ${{ github.event.client_payload.pull_request.body }}
draft: true
prerelease: false
generate_release_notes: true
5 changes: 4 additions & 1 deletion .github/workflows/shift_left.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: ShiftLeft Scan

on: push
on:
push:
pull_request:
types: [synchronize, opened]

jobs:
Scan-Build:
Expand Down

0 comments on commit b1c87ec

Please sign in to comment.