Skip to content

output dir contents #42

output dir contents

output dir contents #42

Workflow file for this run

# trunk-ignore-all(checkov/CKV2_GHA_1)
# This is a basic workflow to help you get started with Actions
name: build
# Controls when the workflow will run
on:
# Triggers after test.yml
# workflow_run:
# workflows: [functionality]
# types:
# - completed
push:
tags:
- "**"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
#Job1
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# outputs:
# cache-key: ${{ steps.build-script.outputs.CACHE_KEY }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.20.0'
# Runs a set of commands using the runners shell
- name: build-script
id: build-script
run: |
cd ${{ github.workspace }}
mkdir bin
mkdir bin/flowcat-darwin-arm64
mkdir bin/flowcat-linux-386
mkdir bin/flowcat-linux-amd64
go test release_test.go
if [ `echo $?` -ne 0 ]; then exit 1; fi
ls bin/flowcat-darwin-arm64/
echo "${{ hashFiles('bin/flowcat-darwin-arm64/flowcat') }}"
echo "CACHE_KEY=${{ hashFiles('bin/flowcat-darwin-arm64/flowcat') }}" >> $GITHUB_ENV
- name: upload-darwin-arm64-cache
id: darwin-arm64-cache
uses: actions/cache/save@v3
with:
path: |
bin
bin/*
bin/flowcat-darwin-arm64/flowcat
key: ${{ hashFiles('bin/flowcat-darwin-arm64/flowcat') }}
# - name: upload-linux-386-cache
# id: linux-386-cache
# uses: actions/cache/save@v3
# with:
# path: |
# bin
# bin/*
# bin/flowcat-linux-386/flowcat
# key: test
# - name: upload-linux-amd64-cache
# id: linux-amd64-cache
# uses: actions/cache/save@v3
# with:
# path: |
# bin
# bin/*
# bin/flowcat-linux-amd64/flowcat
# key: test
# release:
# name: "Release"
# needs: [build]
# runs-on: "ubuntu-latest"
# # env:
# # OUTPUT: ${{ needs.build.outputs.cache-key }}
# steps:
- name: get-cache
uses: actions/cache/restore@v3
with:
path: |
bin
bin/*
bin/flowcat-darwin-arm64/flowcat
key: ${{ env.CACHE_KEY }}
#key: test
- name: "Determine tag"
run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV && echo \"${{ env.CACHE_KEY }}\""
- name: "Create release"
uses: "actions/github-script@v6"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
try {
const response = await github.rest.repos.createRelease({
draft: true,
generate_release_notes: true,
name: process.env.RELEASE_TAG,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
});
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: response.data.id,
name: "flowcat-darwin-arm64",
data: await fs.readFileSync("bin/flowcat-darwin-arm64/flowcat")
});
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: response.data.id,
name: "flowcat-linux-386",
data: await fs.readFileSync("bin/flowcat-linux-386/flowcat")
});
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: response.data.id,
name: "flowcat-linux-amd64",
data: await fs.readFileSync("bin/flowcat-linux-amd64/flowcat")
});
core.exportVariable('RELEASE_ID', response.data.id);
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url);
} catch (error) {
core.setFailed(error.message);
}