Skip to content

Commit

Permalink
[FIX] release bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ismoilovdevml committed Oct 14, 2023
1 parent 809853a commit 9592bd5
Showing 1 changed file with 110 additions and 76 deletions.
186 changes: 110 additions & 76 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,94 +1,128 @@
name: Release
name: Release CI/CD

on:
push:
branches:
- main
tags:
- 'v0.1.2'
- "v0.1.2"

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: Build and Prepare Artifacts
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl, x86_64-pc-windows-gnu, armv7-unknown-linux-gnueabihf, armv7-unknown-linux-musleabihf]
file-extension: ['', '.exe']
file-extension: [""]
target:
- x86_64-unknown-linux-musl
- x86_64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- armv7-unknown-linux-musleabihf
platform: [ubuntu-20.04]
include:
- target: x86_64-pc-windows-gnu
file-extension: '.exe'

- file-extension: .exe
target: x86_64-pc-windows-gnu
platform: ubuntu-20.04
runs-on: ${{ matrix.platform }}
timeout-minutes: 240 # Increase the timeout to 4 hours
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup | Checkout
uses: actions/checkout@v2

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: ${{ matrix.target }}

- name: Cache Cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache Cargo index
uses: actions/cache@v2
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

- name: Cache Cargo build
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Build | Release
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target ${{ matrix.target }} --release
- name: Cache Cargo build
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}

- name: Prepare Artifacts
run: |
mkdir release
cp target/${{ matrix.target }}/release/ruststrom${{ matrix.file-extension }} release/rust-strom-${{ matrix.target }}-${{ steps.get_version.outputs.VERSION }}${{ matrix.file-extension }}
cp LICENSE README.md install.sh release/
# - name: Setup | Version
# id: get_version
# run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: release-${{ matrix.target }}
path: release/
retention-days: 1
- name: Setup | Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
target: ${{ matrix.target }}
override: true

release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build | Release
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target ${{ matrix.target }} --release

- name: Build | Rename with Target
run: cp target/${{ matrix.target }}/release/ruststrom${{ matrix.file-extension }} rust-strom-${{ matrix.target }}-${{ steps.get_version.outputs.VERSION }}${{ matrix.file-extension }}

- name: Download Artifacts
uses: actions/download-artifact@v2
with:
name: release-${{ matrix.target }}
- name: Release | Upload Artifact
uses: actions/upload-artifact@v2
with:
name: rust-strom-${{ matrix.target }}-${{ steps.get_version.outputs.VERSION }}${{ matrix.file-extension }}
path: rust-strom-${{ matrix.target }}-${{ steps.get_version.outputs.VERSION }}${{ matrix.file-extension }}

- name: Create Release & Upload
uses: gh-actions/gh-release@master
with:
token: ${{ secrets.PERSONAL_TOKEN }}
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: RustStrom LoadBalancer
draft: false
prerelease: false
files: |
release/*
build-docker:
runs-on: ubuntu-20.04
steps:
- name: Setup | Checkout
uses: actions/checkout@v2
- name: Setup | Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: rust-strom/rust-strom-lb
tag-semver: |
{{version}}
{{major}}.{{minor}}
- name: Setup | QEMU
uses: docker/setup-qemu-action@v1
- name: Setup | Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Setup | Docker Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build | Build and Push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}

release:
needs: [build, build-docker]
runs-on: ubuntu-20.04
steps:
- name: Release | Download Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Release | GitHub
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
with:
name: ARLB ${{ github.ref }}
body: |
TODO
draft: true
prerelease: false
files: |
artifacts/**/*
- name: Release | Purge Artifacts
uses: kolpav/purge-artifacts-action@v1
with:
token: ${{ secrets.PERSONAL_TOKEN }}
expire-in: "0d"

0 comments on commit 9592bd5

Please sign in to comment.