Skip to content

Commit

Permalink
fix: attempt to combine the workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Mar 29, 2022
1 parent aef04e9 commit 8d4e0ae
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 197 deletions.
55 changes: 0 additions & 55 deletions .github/actions/s3-upload/action.yaml

This file was deleted.

124 changes: 124 additions & 0 deletions .github/actions/upload-and-notify/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: 'Upload build and notify BitFocus API Server'
description: 'Upload build and notify BitFocus API Server'
inputs:
long-version:
description: 'Long version number (eg 1.0.0+1234-abcdefg)'
required: true
default: ''
beta-branch:
description: 'Name of branch for beta builds'
required: true
default: ''
dev-branch:
description: 'Name of branch for experimental builds'
required: false
default: ''

source-filename:
description: 'File to upload'
required: true
default: ''
destination-filename:
description: 'Target filename in s3'
required: true
default: ''
host:
description: 'Server endpoint'
required: true
default: 's3.bitfocus.io'
bucket:
description: 'Bucket to upload to'
required: true
default: ''
access-key:
description: 'Access Key'
required: true
default: ''
secret-key:
description: 'Secret Key'
required: true
default: ''

product:
description: 'Name of the product'
required: true
default: ''
target:
description: 'Build target (linux-img/linux-deb/linux-tgz/mac-intel/mac-arm/win-x86/win-x64)'
required: true
default: ''
api-secret:
description: 'Secret for the api server'
required: true
default: ''
runs:
using: 'composite'
steps:
- id: versions
name: Determine versions
shell: bash
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]
then
VERSION="${{ github.ref_name }}"
echo "stable release ${VERSION}"
echo ::set-output name=branch::"stable"
echo ::set-output name=version::"${VERSION}"
elif [[ "${{ github.ref }}" == refs/heads/* && "${{ github.ref_name }}" == "${{ inputs.beta-branch }}" ]]
then
VERSION="${{ inputs.long-version }}"
echo "beta build ${VERSION}"
echo ::set-output name=branch::"beta"
echo ::set-output name=version::"${VERSION}"
elif [[ "${{ github.ref }}" == refs/heads/* && "${{ github.ref_name }}" == "${{ inputs.dev-branch }}" ]]
then
VERSION="${{ inputs.long-version }}"
echo "dev build ${VERSION}"
echo ::set-output name=branch::"experimental"
echo ::set-output name=version::"${VERSION}"
else
echo "not uploading"
fi
- name: Download minio client
if: runner.os == 'Linux' && ${{ steps.versions.outputs.version }} && ${{ steps.versions.outputs.branch }}
shell: bash
run: |
wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
- name: Download minio client
if: runner.os == 'Windows' && ${{ steps.versions.outputs.version }} && ${{ steps.versions.outputs.branch }}
shell: pwsh
run: |
Invoke-WebRequest -Uri "https://dl.minio.io/client/mc/release/windows-amd64/mc.exe" -OutFile "./mc"
chmod +x mc
- name: Download minio client
if: runner.os == 'macOS' && ${{ steps.versions.outputs.version }} && ${{ steps.versions.outputs.branch }}
shell: bash
run: |
wget https://dl.min.io/client/mc/release/darwin-amd64/mc
chmod +x mc
- name: Upload file
if: ${{ steps.versions.outputs.version }} && ${{ steps.versions.outputs.branch }}
shell: bash
run: |
./mc alias set remote/ https://${{ inputs.host }} ${{ inputs.access-key }} ${{ inputs.secret-key }}
./mc cp "${{ inputs.source-filename }}" "remote/${{ inputs.bucket }}/${{ inputs.destination-filename }}"
- name: Notify API Server
if: ${{ steps.versions.outputs.version }} && ${{ steps.versions.outputs.branch }}
shell: bash
run: |
curl -X 'POST' \
'https://api.bitfocus.io/v1/product/${{ inputs.product }}/package' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"branch": "${{ steps.versions.outputs.branch }}",
"version": "${{ steps.versions.outputs.version }}",
"target": "${{ inputs.target }}",
"filename": "${{ inputs.destination-filename }}",
"secret": "${{ inputs.api-secret }}"
}'
50 changes: 0 additions & 50 deletions .github/actions/versions/action.yaml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/actions/webhook/action.yaml

This file was deleted.

60 changes: 12 additions & 48 deletions .github/workflows/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,21 @@ jobs:
echo ::set-output name=targetname::"companion-satellite-x64-${COUNT}-${HASH}.tar.gz"
echo ::set-output name=longversion::"${VERSION}+${COUNT}-${HASH}"
- name: Versions
id: versions
uses: ./.github/actions/versions
- name: Upload build
uses: ./.github/actions/upload-and-notify
with:
long-version: ${{ steps.filenames.outputs.longversion }}
beta-branch: master

- name: Upload app
if: ${{ steps.versions.outputs.version }} && ${{ steps.versions.outputs.branch }}
uses: ./.github/actions/s3-upload
with:
source-filename: ${{ steps.filenames.outputs.sourcename }}
destination-filename: companion-satellite/${{ steps.filenames.outputs.targetname }}
destination-filename: ${{ steps.filenames.outputs.targetname }}
host: ${{ secrets.S3_HOST }}
bucket: ${{ secrets.S3_BUCKET }}
bucket: ${{ secrets.S3_BUCKET }}/companion-satellite
access-key: ${{ secrets.S3_KEY }}
secret-key: ${{ secrets.S3_SECRET }}

- name: Notify API Server'
if: ${{ steps.versions.outputs.version }} && ${{ steps.versions.outputs.branch }}
uses: ./.github/actions/webhook
with:
product: companion-satellite
branch: ${{ steps.versions.outputs.branch }}
version: ${{ steps.versions.outputs.version }}
target: 'linux-tgz'
filename: ${{ steps.filenames.outputs.targetname }}
secret: ${{ secrets.BITFOCUS_API_PROJECT_SECRET }}

Windows-x64:
Expand Down Expand Up @@ -99,33 +87,21 @@ jobs:
echo ::set-output name=targetname::"companion-satellite-x64-${COUNT}-${HASH}.exe"
echo ::set-output name=longversion::"${VERSION}"
- name: Versions
id: versions
uses: ./.github/actions/versions
- name: Upload build
uses: ./.github/actions/upload-and-notify
with:
long-version: ${{ steps.filenames.outputs.longversion }}
beta-branch: master

- name: Upload app
if: ${{ steps.filenames.outputs.sourcename }} && ${{ steps.versions.outputs.version }} && ${{ steps.versions.outputs.branch }}
uses: ./.github/actions/s3-upload
with:
source-filename: ${{ steps.filenames.outputs.sourcename }}
destination-filename: companion-satellite/${{ steps.filenames.outputs.targetname }}
destination-filename: ${{ steps.filenames.outputs.targetname }}
host: ${{ secrets.S3_HOST }}
bucket: ${{ secrets.S3_BUCKET }}
bucket: ${{ secrets.S3_BUCKET }}/companion-satellite
access-key: ${{ secrets.S3_KEY }}
secret-key: ${{ secrets.S3_SECRET }}

- name: Notify API Server'
if: ${{ steps.filenames.outputs.targetname }} && ${{ steps.versions.outputs.version }} && ${{ steps.versions.outputs.branch }}
uses: ./.github/actions/webhook
with:
product: companion-satellite
branch: ${{ steps.versions.outputs.branch }}
version: ${{ steps.versions.outputs.version }}
target: 'win-x64'
filename: ${{ steps.filenames.outputs.targetname }}
secret: ${{ secrets.BITFOCUS_API_PROJECT_SECRET }}

Mac-x64:
Expand Down Expand Up @@ -164,31 +140,19 @@ jobs:
echo ::set-output name=targetname::"companion-satellite-x64-${COUNT}-${HASH}.dmg"
echo ::set-output name=longversion::"${VERSION}"
- name: Versions
id: versions
uses: ./.github/actions/versions
- name: Upload build
uses: ./.github/actions/upload-and-notify
with:
long-version: ${{ steps.filenames.outputs.longversion }}
beta-branch: master

- name: Upload app
if: ${{ steps.filenames.outputs.sourcename }} && ${{ steps.versions.outputs.version }} && ${{ steps.versions.outputs.branch }}
uses: ./.github/actions/s3-upload
with:
source-filename: ${{ steps.filenames.outputs.sourcename }}
destination-filename: companion-satellite/${{ steps.filenames.outputs.targetname }}
destination-filename: ${{ steps.filenames.outputs.targetname }}
host: ${{ secrets.S3_HOST }}
bucket: ${{ secrets.S3_BUCKET }}
bucket: ${{ secrets.S3_BUCKET }}/companion-satellite
access-key: ${{ secrets.S3_KEY }}
secret-key: ${{ secrets.S3_SECRET }}

- name: Notify API Server'
if: ${{ steps.filenames.outputs.targetname }} && ${{ steps.versions.outputs.version }} && ${{ steps.versions.outputs.branch }}
uses: ./.github/actions/webhook
with:
product: companion-satellite
branch: ${{ steps.versions.outputs.branch }}
version: ${{ steps.versions.outputs.version }}
target: 'mac-x64'
filename: ${{ steps.filenames.outputs.targetname }}
secret: ${{ secrets.BITFOCUS_API_PROJECT_SECRET }}

0 comments on commit 8d4e0ae

Please sign in to comment.