Skip to content

Commit

Permalink
style: change yaml file to 2-space
Browse files Browse the repository at this point in the history
  • Loading branch information
moz-sec committed Jul 23, 2024
1 parent e4f9926 commit 10c9116
Showing 1 changed file with 151 additions and 151 deletions.
302 changes: 151 additions & 151 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,168 +1,168 @@
name: publish_site_release_assets
on:
pull_request:
branches:
- main
types: [closed]
pull_request:
branches:
- main
types: [closed]

jobs:
setup:
runs-on: ubuntu-latest
if: startsWith(github.head_ref, 'release/v') && github.event.pull_request.merged == true
outputs:
appname: unicom
tag: ${{ steps.vars.outputs.tag }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Git Tag name
id: vars
run: |
echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF (${GITHUB_HEAD_REF##*/v})"
echo "tag=${GITHUB_HEAD_REF##*/v}" >> $GITHUB_OUTPUT
setup:
runs-on: ubuntu-latest
if: startsWith(github.head_ref, 'release/v') && github.event.pull_request.merged == true
outputs:
appname: unicom
tag: ${{ steps.vars.outputs.tag }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Git Tag name
id: vars
run: |
echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF (${GITHUB_HEAD_REF##*/v})"
echo "tag=${GITHUB_HEAD_REF##*/v}" >> $GITHUB_OUTPUT
- name: Create release
id: create_release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: v${{ steps.vars.outputs.tag }}
title: Release v${{ steps.vars.outputs.tag }}
draft: false
prerelease: false
- name: Create release
id: create_release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: v${{ steps.vars.outputs.tag }}
title: Release v${{ steps.vars.outputs.tag }}
draft: false
prerelease: false

publish:
runs-on: ${{ matrix.os }}
needs: setup
strategy:
matrix:
include:
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
artifact_name: ${{ needs.setup.outputs.appname }}
asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_linux_arm64
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: ${{ needs.setup.outputs.appname }}
asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_linux_amd64
# - os: ubuntu-latest
# target: aarch64-pc-windows-gnullvm
# artifact_name: ${{ needs.setup.outputs.appname }}.exe
# asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_windows_arm64
- os: ubuntu-latest
target: x86_64-pc-windows-gnu
artifact_name: ${{ needs.setup.outputs.appname }}.exe
asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_windows_amd64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: ${{ needs.setup.outputs.appname }}
asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_darwin_arm64
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: ${{ needs.setup.outputs.appname }}
asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_darwin_amd64
publish:
runs-on: ${{ matrix.os }}
needs: setup
strategy:
matrix:
include:
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
artifact_name: ${{ needs.setup.outputs.appname }}
asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_linux_arm64
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: ${{ needs.setup.outputs.appname }}
asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_linux_amd64
# - os: ubuntu-latest
# target: aarch64-pc-windows-gnullvm
# artifact_name: ${{ needs.setup.outputs.appname }}.exe
# asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_windows_arm64
- os: ubuntu-latest
target: x86_64-pc-windows-gnu
artifact_name: ${{ needs.setup.outputs.appname }}.exe
asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_windows_amd64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: ${{ needs.setup.outputs.appname }}
asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_darwin_arm64
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: ${{ needs.setup.outputs.appname }}
asset_name: ${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}_darwin_amd64


steps:
# initialization
- name: Checkout the project
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
steps:
# initialization
- name: Checkout the project
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod

- name: Setup variables
id: vars
shell: bash
run: |
DIR=$(echo "${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}")
echo "dir=$DIR" >> $GITHUB_OUTPUT
- name: Setup variables
id: vars
shell: bash
run: |
DIR=$(echo "${{ needs.setup.outputs.appname }}-${{ needs.setup.outputs.tag }}")
echo "dir=$DIR" >> $GITHUB_OUTPUT
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Setup
run: rustup update stable
- name: Setup
run: rustup update stable

- name: Setup Rust (1/2) (toolchain)
uses: taiki-e/setup-cross-toolchain-action@v1
if: matrix.os == 'ubuntu-latest'
with:
target: ${{ matrix.target }}
- name: Setup Rust (1/2) (toolchain)
uses: taiki-e/setup-cross-toolchain-action@v1
if: matrix.os == 'ubuntu-latest'
with:
target: ${{ matrix.target }}

- name: Cross build (macOS)
if: matrix.os == 'macos-latest'
run: |
rustup target add ${{ matrix.target }}
cargo build --release --target ${{ matrix.target }}
- name: Cross build (macOS)
if: matrix.os == 'macos-latest'
run: |
rustup target add ${{ matrix.target }}
cargo build --release --target ${{ matrix.target }}
- name: Cross build (Linux and Windows)
run: |
cargo build --release --target ${{ matrix.target }}
- name: Cross build (Linux and Windows)
run: |
cargo build --release --target ${{ matrix.target }}
# publish release
- name: Create release file
shell: bash
run: |
DIR=${{ steps.vars.outputs.dir }}
DIST=${{ matrix.target }}
mkdir -p dist/$DIST/$DIR
# cp -r site/public dist/$DIST/$DIR/docs
cp -r README.md LICENSE target/completions target/${{ matrix.target }}/release/${{ matrix.artifact_name }} dist/$DIST/$DIR
tar cvfz dist/${{ matrix.asset_name }}.tar.gz -C dist/$DIST $DIR
# publish release
- name: Create release file
shell: bash
run: |
DIR=${{ steps.vars.outputs.dir }}
DIST=${{ matrix.target }}
mkdir -p dist/$DIST/$DIR
# cp -r site/public dist/$DIST/$DIR/docs
cp -r README.md LICENSE target/completions target/${{ matrix.target }}/release/${{ matrix.artifact_name }} dist/$DIST/$DIR
tar cvfz dist/${{ matrix.asset_name }}.tar.gz -C dist/$DIST $DIR
- name: Upload release assets
id: upload-release-assets
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_path: dist/${{ matrix.asset_name }}.tar.gz
asset_name: ${{ matrix.asset_name }}.tar.gz
asset_content_type: application/x-gzip
upload_url: ${{ needs.setup.outputs.upload_url }}
- name: Upload release assets
id: upload-release-assets
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_path: dist/${{ matrix.asset_name }}.tar.gz
asset_name: ${{ matrix.asset_name }}.tar.gz
asset_content_type: application/x-gzip
upload_url: ${{ needs.setup.outputs.upload_url }}

docker:
needs: publish
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Docker buildx
uses: docker/setup-buildx-action@v2
- name: Metadata
id: meta
uses: docker/metadata-action@v5
with:
# ${{ github.repository }} = moz-sec/unicom
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=latest
type=sha,prefix=,suffix=,format=short
type=raw,value=${{ needs.publish.outputs.tag }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout the project
uses: actions/checkout@v4
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from:
type=registry,ref=ghcr.io/${{ github.repository}}:buildcache
cache-to:
type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max
docker:
needs: publish
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Docker buildx
uses: docker/setup-buildx-action@v2
- name: Metadata
id: meta
uses: docker/metadata-action@v5
with:
# ${{ github.repository }} = moz-sec/unicom
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=latest
type=sha,prefix=,suffix=,format=short
type=raw,value=${{ needs.publish.outputs.tag }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout the project
uses: actions/checkout@v4
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from:
type=registry,ref=ghcr.io/${{ github.repository}}:buildcache
cache-to:
type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max

0 comments on commit 10c9116

Please sign in to comment.