Skip to content

test for assets

test for assets #24

Workflow file for this run

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 }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }} # This is the upload URL for the release assets
asset_path: ./path_to_your_executable/mediarizer2-${{ matrix.OS }}-${{ matrix.ARCH }}${{ matrix.EXT }}
asset_name: mediarizer2-${{ matrix.OS }}-${{ matrix.ARCH }}${{ matrix.EXT }}
asset_content_type: application/octet-stream
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: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.run_number }}
release_name: Release ${{ github.ref_name }} (${{ github.run_number }})
body: |
- Commits included:
${{ steps.get_commits.outputs.commits }}
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_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 @$file ${{ steps.create_release.outputs.upload_url }}?name=$asset_name
done