Skip to content

Merge pull request #75 from ApplauseOSS/dependabot/go_modules/github.… #3

Merge pull request #75 from ApplauseOSS/dependabot/go_modules/github.…

Merge pull request #75 from ApplauseOSS/dependabot/go_modules/github.… #3

Workflow file for this run

name: publish
on:
push:
tags:
- 'v*.*.*'
concurrency: ${{ github.ref }}
jobs:
create-draft-release:
runs-on: ubuntu-latest
outputs:
RELEASE_ID: ${{ steps.create-release.outputs.result }}
steps:
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
- uses: actions/github-script@v6
id: create-release
if: startsWith(github.ref, 'refs/tags/')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
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,
});
return response.data.id;
} catch (error) {
core.setFailed(error.message);
}
build-binaries:
strategy:
matrix:
os: [linux, darwin, freebsd, windows]
arch: [amd64, arm64]
runs-on: ubuntu-latest
needs: [create-draft-release]
steps:
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Build binary
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} make build
- name: Upload release asset
run: |
_filename=decrypt-and-start_${{ env.RELEASE_TAG }}_${{ matrix.os }}_${{ matrix.arch }}
if [[ ${{ matrix.os }} == windows ]]; then
_filename=${_filename}.exe
fi
mv decrypt-and-start ${_filename}
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @${_filename} \
https://uploads.github.com/repos/${{ github.repository_owner }}/decrypt-and-start/releases/${{ needs.create-draft-release.outputs.RELEASE_ID }}/assets?name=${_filename}
finalize-release:
runs-on: ubuntu-latest
needs: [create-draft-release, build-binaries]
steps:
- uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ needs.create-draft-release.outputs.RELEASE_ID }},
draft: false,
});
} catch (error) {
core.setFailed(error.message);
}