From 840236ecc49b6bf10cc4cfd09afa49f6e21b9f69 Mon Sep 17 00:00:00 2001 From: Hellojack <106379370+H1JK@users.noreply.github.com> Date: Mon, 24 Oct 2022 16:38:02 +0800 Subject: [PATCH] Update workflow output usage --- .github/workflows/build.yaml | 3 ++- .github/workflows/release.yaml | 2 +- main.go | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0826cf9..438d7de 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,5 +1,6 @@ name: Build on: + workflow_dispatch: push: branches: - main @@ -15,7 +16,7 @@ jobs: - name: Get latest go version id: version run: | - echo ::set-output name=go_version::$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') + echo "go_version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g')" >> $GITHUB_OUTPUT - name: Setup Go uses: actions/setup-go@v3 with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c271061..b0120c3 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -15,7 +15,7 @@ jobs: - name: Get latest go version id: version run: | - echo ::set-output name=go_version::$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g') + echo "go_version=$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '"version": "[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/"//g')" >> $GITHUB_OUTPUT - name: Setup Go uses: actions/setup-go@v3 with: diff --git a/main.go b/main.go index efcacf3..0c6e2b6 100644 --- a/main.go +++ b/main.go @@ -186,7 +186,10 @@ func generate(release *github.RepositoryRelease, output string) error { } func setActionOutput(name string, content string) { - os.Stdout.WriteString("::set-output name=" + name + "::" + content + "\n") + f, err := os.OpenFile(os.Getenv("GITHUB_OUTPUT"), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600) + common.Must(err) + defer f.Close() + common.Must1(f.WriteString(name + "=" + content + "\n")) } func release(source string, destination string, output string) error {