mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-25 13:39:22 +00:00
180 lines
5.1 KiB
YAML
180 lines
5.1 KiB
YAML
name: build
|
|
|
|
on:
|
|
push:
|
|
tags: ['v*', 'test*']
|
|
|
|
jobs:
|
|
build_macos:
|
|
name: Build for MacOS
|
|
runs-on: macos-13
|
|
steps:
|
|
- name: "Checkout"
|
|
uses: actions/checkout@v2
|
|
with:
|
|
submodules: 'recursive'
|
|
- name: "Setup Go"
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: '^1.17'
|
|
- name: Cache Go Modules
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
- name: "Build"
|
|
run: make build_macos
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: macos
|
|
path: _output/macos/yarr.app
|
|
|
|
build_windows:
|
|
name: Build for Windows
|
|
runs-on: windows-2022
|
|
steps:
|
|
- name: "Checkout"
|
|
uses: actions/checkout@v2
|
|
with:
|
|
submodules: 'recursive'
|
|
- name: "Setup Go"
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: '^1.17'
|
|
- name: Cache Go Modules
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
- name: "Build"
|
|
run: make build_windows
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: windows
|
|
path: _output/windows/yarr.exe
|
|
|
|
build_linux:
|
|
name: Build for Linux
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: "Checkout"
|
|
uses: actions/checkout@v2
|
|
with:
|
|
submodules: 'recursive'
|
|
- name: "Setup Go"
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: '^1.17'
|
|
- name: Cache Go Modules
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-
|
|
- name: "Build"
|
|
run: make build_linux
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: linux
|
|
path: _output/linux/yarr
|
|
|
|
create_release:
|
|
name: Create Release
|
|
runs-on: ubuntu-latest
|
|
if: ${{ !contains(github.ref, 'test') }}
|
|
needs: [build_macos, build_windows, build_linux]
|
|
steps:
|
|
- name: Create Release
|
|
uses: actions/create-release@v1
|
|
id: create_release
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ github.ref }}
|
|
release_name: ${{ github.ref }}
|
|
draft: true
|
|
prerelease: true
|
|
- name: Download Artifacts
|
|
uses: actions/download-artifact@v2
|
|
with:
|
|
path: .
|
|
- name: Preparation
|
|
run: |
|
|
ls -R
|
|
chmod u+x macos/Contents/MacOS/yarr
|
|
chmod u+x linux/yarr
|
|
|
|
mv macos yarr.app && zip -r yarr-macos.zip yarr.app
|
|
mv windows/yarr.exe . && zip yarr-windows.zip yarr.exe
|
|
mv linux/yarr . && zip yarr-linux.zip yarr
|
|
- name: Upload MacOS
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
asset_path: ./yarr-macos.zip
|
|
asset_name: yarr-${{ github.ref }}-macos64.zip
|
|
asset_content_type: application/zip
|
|
- name: Upload Windows
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
asset_path: ./yarr-windows.zip
|
|
asset_name: yarr-${{ github.ref }}-windows64.zip
|
|
asset_content_type: application/zip
|
|
- name: Upload Linux
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
asset_path: ./yarr-linux.zip
|
|
asset_name: yarr-${{ github.ref }}-linux64.zip
|
|
asset_content_type: application/zip
|
|
|
|
build_docker:
|
|
runs-on: ubuntu-latest
|
|
needs: [create_release]
|
|
steps:
|
|
- name: Read latest release tag
|
|
id: read-tag
|
|
run: |
|
|
echo ::set-output name=tag::$(curl -sL https://raw.githubusercontent.com/rebron1900/yarr/master/yarr-version.txt)
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
repository: 'rebron1900/yarr'
|
|
ref: ${{ steps.read-tag.outputs.tag }}
|
|
- name: Remove GOARCH
|
|
run: |
|
|
sed -i -e 's/GOARCH=amd64//g' makefile
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v1
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
- name: Login to registry
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
- name: Push to Docker
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
push: true
|
|
tags: |
|
|
${{ secrets.DOCKER_USERNAME }}/yarr:latest
|
|
${{ secrets.DOCKER_USERNAME }}/yarr:${{ steps.read-tag.outputs.tag }}
|