Skip to content

Merge pull request #40 from sangmo-kang/sangmo-kang-patch-2 #121

Merge pull request #40 from sangmo-kang/sangmo-kang-patch-2

Merge pull request #40 from sangmo-kang/sangmo-kang-patch-2 #121

Workflow file for this run

name: C/C++ CI
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
bump-tag-dry:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get next version
id: tag
uses: anothrNick/github-tag-action@1.67.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
DRY_RUN: true
- name: create tag file
run: |
echo ${{ steps.tag.outputs.new_tag }} > tag.txt
- name: upload new tag artifact
uses: actions/upload-artifact@v1
with:
name: uploads
path: tag.txt
build-linux:
runs-on: ubuntu-latest
needs: [bump-tag-dry]
steps:
- uses: actions/checkout@v4
- name: download artifacts
uses: actions/download-artifact@v1
with:
name: uploads
- uses: actions/setup-node@v4
with:
node-version: 18
- name: build
run: |
npm install -g bats
export DUPLO_VERSION=`cat ./uploads/tag.txt`
mkdir -p build
pushd build
cmake .. -DDUPLO_VERSION=\"$DUPLO_VERSION\"
make
popd
zip --junk-paths duplo-linux build/duplo
- name: upload linux artifact
uses: actions/upload-artifact@v1
with:
name: uploads
path: duplo-linux.zip
build-macos:
runs-on: macos-latest
needs: [bump-tag-dry]
steps:
- uses: actions/checkout@v4
- name: download artifacts
uses: actions/download-artifact@v1
with:
name: uploads
- name: build
run: |
brew install bats-core
export DUPLO_VERSION=`cat ./uploads/tag.txt`
mkdir -p build
pushd build
cmake .. -DDUPLO_VERSION=\"$DUPLO_VERSION\"
popd
./compile.sh
zip --junk-paths duplo-macos build/duplo
- name: upload macos artifact
uses: actions/upload-artifact@v1
with:
name: uploads
path: duplo-macos.zip
push-docker-image:
runs-on: ubuntu-latest
needs: [bump-tag-dry]
steps:
- name: download artifacts
uses: actions/download-artifact@v1
with:
name: uploads
- name: set version
id: version
run: |
DUPLO_VERSION=$(cat ./uploads/tag.txt)
echo $DUPLO_VERSION
echo "DUPLO_VERSION=$DUPLO_VERSION" >> $GITHUB_ENV
echo "DUPLO_VERSION=$DUPLO_VERSION" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker build
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v5
with:
push: false
tags: "dlidstrom/duplo:${{ steps.version.outputs.DUPLO_VERSION }}"
build-args: |
"DUPLO_VERSION=${{ steps.version.outputs.DUPLO_VERSION }}"
- name: Docker build and push
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v5
with:
push: true
tags: "dlidstrom/duplo:latest,dlidstrom/duplo:${{ steps.version.outputs.DUPLO_VERSION }}"
build-args: |
"DUPLO_VERSION=${{ steps.version.outputs.DUPLO_VERSION }}"
upload-release:
if: success()
runs-on: ubuntu-latest
needs: [build-linux, build-macos]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Bump version and push tag
id: tag
uses: anothrNick/github-tag-action@1.36.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
- name: create release
id: create_release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.tag }}
release_name: Release ${{ steps.tag.outputs.tag }}
draft: false
prerelease: false
- name: download artifacts
uses: actions/download-artifact@v1
with:
name: uploads
- name: upload macos
id: upload-macos
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./uploads/duplo-macos.zip
asset_name: duplo-macos.zip
asset_content_type: application/zip
- name: upload linux
id: upload-linux
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./uploads/duplo-linux.zip
asset_name: duplo-linux.zip
asset_content_type: application/zip