Put download link in the body of the release #35
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go Build and Release | |
# on: | |
# push: | |
# tags: | |
# - 'v*' | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- OS: linux | |
ARCH: amd64 | |
EXT: "bin" | |
- OS: windows | |
ARCH: amd64 | |
EXT: "exe" | |
- OS: darwin | |
ARCH: amd64 | |
EXT: "app" | |
- OS: darwin | |
ARCH: arm64 | |
EXT: "app" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.22' | |
- name: Build | |
run: | | |
GOOS=${{ matrix.OS }} GOARCH=${{ matrix.ARCH }} | |
go build -v -o mediarizer2-${{ matrix.OS }}-${{ matrix.ARCH }}.${{ matrix.EXT }} ./app | |
env: | |
GOOS: ${{ matrix.OS }} | |
GOARCH: ${{ matrix.ARCH }} | |
EXT: ${{ matrix.EXT }} | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: mediarizer2-${{ matrix.OS }}-${{ matrix.ARCH }}.${{ matrix.EXT }} | |
path: mediarizer2-${{ matrix.OS }}-${{ matrix.ARCH }}.${{ matrix.EXT }} | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
# if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Fetch Tags | |
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
- name: Get commits since last tag | |
id: get_commits | |
run: | | |
LATEST_TAG=$(git describe --tags --abbrev=0 --always) | |
if [ -z "$LATEST_TAG" ] || [[ "$LATEST_TAG" == *"$GITHUB_SHA"* ]]; then | |
LATEST_TAG=$(git rev-list --max-parents=0 HEAD) | |
fi | |
COMMIT_MESSAGES=$(git log $LATEST_TAG..HEAD --pretty=format:"%h - %s") | |
echo "::set-output name=commits::$COMMIT_MESSAGES" | |
- name: Get Artifact IDs | |
id: get_artifacts | |
run: | | |
ARTIFACTS=$(curl \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
"${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts") | |
WINDOWS_ARTIFACT_ID=$(echo $ARTIFACTS | jq -r '.artifacts[] | select(.name=="mediarizer2-windows-amd64.exe") | .id') | |
LINUX_ARTIFACT_ID=$(echo $ARTIFACTS | jq -r '.artifacts[] | select(.name=="mediarizer2-linux-amd64.bin") | .id') | |
DARWIN_AMD64_ARTIFACT_ID=$(echo $ARTIFACTS | jq -r '.artifacts[] | select(.name=="mediarizer2-darwin-amd64.app") | .id') | |
DARWIN_ARM64_ARTIFACT_ID=$(echo $ARTIFACTS | jq -r '.artifacts[] | select(.name=="mediarizer2-darwin-arm64.app") | .id') | |
echo "::set-output name=windows::$WINDOWS_ARTIFACT_ID" | |
echo "::set-output name=linux::$LINUX_ARTIFACT_ID" | |
echo "::set-output name=darwin_amd64::$DARWIN_AMD64_ARTIFACT_ID" | |
echo "::set-output name=darwin_arm64::$DARWIN_ARM64_ARTIFACT_ID" | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref_name }} | |
release_name: Release ${{ github.ref_name }} | |
body: | | |
- Commits included: | |
${{ steps.get_commits.outputs.commits }} | |
- Binaries: | |
[mediarizer2-windows-amd64.exe](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.get_artifacts.outputs.windows }}) | |
[mediarizer2-linux-amd64.bin](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.get_artifacts.outputs.linux }}) | |
[mediarizer2-darwin-amd64.app](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.get_artifacts.outputs.darwin_amd64 }}) | |
[mediarizer2-darwin-arm64.app](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.get_artifacts.outputs.darwin_arm64 }}) | |
draft: false | |
prerelease: false | |
- name: Download Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: ./ | |
- name: Upload Release Assets | |
run: | | |
for file in mediarizer2-*; do | |
echo "Uploading $file" | |
asset_path="$file" | |
asset_name=$(basename $file) | |
echo "Asset Name: $asset_name" | |
curl \ | |
-X POST \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: application/octet-stream" \ | |
--data-binary "@$asset_path" \ | |
"${{ steps.create_release.outputs.upload_url }}?name=$(urlencode $asset_name)" | |
done |