Release #416
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
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
test_build: | |
description: 'Create test builds' | |
type: boolean | |
required: true | |
default: false | |
pull_request_target: | |
types: | |
- closed | |
branches: | |
- main | |
paths-ignore: | |
- '**.md' | |
- '**.png' | |
# push: | |
# branches: | |
# - main | |
# paths-ignore: | |
# - '**.md' | |
env: | |
REGISTRY_IMAGE: ghcr.io/lostb1t/replex | |
permissions: | |
contents: write | |
pull-requests: write | |
concurrency: | |
group: release | |
# If this is enabled it will cancel current running and start latest | |
cancel-in-progress: true | |
jobs: | |
get-next-version: | |
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' | |
uses: semantic-release-action/next-release-version/.github/workflows/next-release-version.yml@v4 | |
# test: | |
# name: Test | |
# runs-on: ubuntu-20.04 | |
# continue-on-error: false | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@v3 | |
# - name: Install Rust | |
# uses: dtolnay/rust-toolchain@stable | |
# - name: Run Tests | |
# run: make run-tests | |
# shell: bash | |
build: | |
if: needs.get-next-version.outputs.new-release-published == 'true' || inputs.test_build | |
name: Build - ${{ matrix.platform.release_for }} | |
strategy: | |
matrix: | |
platform: | |
- release_for: x86_64 Linux | |
os: ubuntu-22.04 | |
docker: linux/amd64 | |
target: x86_64-unknown-linux-gnu | |
bin: replex | |
name: x86_64-unknown-linux-gnu.tar.gz | |
command: build | |
- release_for: ARM64 Linux | |
os: ubuntu-22.04 | |
docker: linux/arm64 | |
target: aarch64-unknown-linux-gnu | |
bin: replex | |
name: aarch64-unknown-linux-gnu.tar.gz | |
command: build | |
# - release_for: x86_64 macOS | |
# os: macOS-latest | |
# docker: darwin/amd64 | |
# target: x86_64-apple-darwin | |
# bin: replex | |
# name: x86_64-apple-darwin.tar.gz | |
# command: build | |
# - release_for: ARM64 macOS | |
# os: macOS-latest | |
# target: aarch64-apple-darwin | |
# bin: replex | |
# name: aarch64-apple-darwin.tar.gz | |
# command: build | |
#- release_for: x86_64 Windows | |
# os: windows-latest | |
# target: x86_64-pc-windows-msvc | |
# bin: replex.exe | |
# name: precious-Windows-x86_64.zip | |
# command: build | |
runs-on: ${{ matrix.platform.os }} | |
needs: | |
- get-next-version | |
env: | |
HUSKY: 0 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Cache cargo & target directories | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ matrix.platform.target }} | |
- name: Install semantic-release-cargo | |
if: ${{ !inputs.test_build }} | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: semantic-release-cargo@2 | |
- name: Prepare semantic-release for Rust | |
if: ${{ !inputs.test_build }} | |
run: semantic-release-cargo prepare ${{ needs.get-next-version.outputs.new-release-version }} | |
- name: Build binary | |
uses: houseabsolute/actions-rust-cross@v0 | |
# env: | |
# CARGO_TARGET_DIR: ./ci-target | |
with: | |
command: ${{ matrix.platform.command }} | |
target: ${{ matrix.platform.target }} | |
args: "--locked --release" | |
- name: Move bin | |
shell: bash | |
run: | | |
mkdir -p bin/${{ matrix.platform.target }} | |
mv target/${{ matrix.platform.target }}/release/replex bin/${{ matrix.platform.target }}/${{ matrix.platform.bin }} | |
- | |
name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
# name: ${{ matrix.platform.target }} | |
name: bin | |
path: bin/* | |
if-no-files-found: error | |
retention-days: 1 | |
# - | |
# name: Build image and push by digest | |
# id: build | |
# uses: docker/build-push-action@v4 | |
# with: | |
# context: . | |
# file: docker/Dockerfile.test.github | |
# platforms: ${{ matrix.platform.docker }} | |
# labels: ${{ steps.meta.outputs.labels }} | |
# # tags: | | |
# # user/app:latest | |
# # user/app:1.0.0 | |
# # ghcr.io/user/app:latest | |
# # ghcr.io/user/app:1.0.0 | |
# outputs: type=image,name=${{ env.REGISTRY_IMAGE }}push-by-digest=true,name-canonical=true,push=true | |
# - | |
# name: Export digest | |
# run: | | |
# mkdir -p /tmp/digests | |
# digest="${{ steps.build.outputs.digest }}" | |
# touch "/tmp/digests/${digest#sha256:}" | |
# - | |
# name: Upload digest | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: digests | |
# path: /tmp/digests/* | |
# if-no-files-found: error | |
# retention-days: 1 | |
# - name: Invoke semantic-release | |
# if: ${{ !inputs.test_build }} | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }} | |
# run: npx semantic-release | |
build-docker-images: | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- get-next-version | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- | |
name: Download bin | |
uses: actions/download-artifact@v3 | |
with: | |
name: bin | |
path: bin/ | |
- name: check bin path | |
run: ls -al bin | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- | |
name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
${{ env.REGISTRY_IMAGE }} | |
tags: | | |
type=raw,value=${{ needs.get-next-version.outputs.new-release-version }},enable={{is_default_branch}} | |
type=raw,value=latest,enable={{is_default_branch}} | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.PERSONAL_TOKEN }} | |
- | |
name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: setup qemu | |
uses: docker/setup-qemu-action@v2 | |
- uses: docker/build-push-action@v4 | |
with: | |
push: true | |
# push: ${{ github.event_name != 'pull_request' }} | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
# file: ./.github/workflows/Dockerfile.ci | |
file: docker/Dockerfile.github | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-to: type=gha,mode=max | |
cache-from: type=gha | |
release: | |
if: ${{ !inputs.test_build }} | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
env: | |
HUSKY: 0 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- | |
name: Download bin | |
uses: actions/download-artifact@v3 | |
with: | |
name: bin | |
path: bin/ | |
- name: Package as archive | |
shell: bash | |
run: | | |
mkdir -p assets | |
cd bin | |
for dir in */; do | |
( | |
cd $dir | |
name=${dir%/} | |
if [[ "$name" == *"windows"* ]]; then | |
7z a ../../assets/$name.7z ./ | |
else | |
chmod +x ./replex | |
tar czvf ../../assets/$name.tar.gz ./ | |
fi | |
) | |
done | |
cd - | |
- name: Invoke semantic-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }} | |
run: npx semantic-release@22 | |