Skip to content

Add checkout

Add checkout #18

Workflow file for this run

name: Go Build and Release
# on:
# push:
# tags:
# - 'v*'
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
OS: [linux, windows]
ARCH: [amd64]
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 }}
EXT=""
if [ "$GOOS" = "windows" ]; then
EXT=".exe"
fi
go build -v -o mediarizer2-${{ matrix.ARCH }}-${{ matrix.OS }}$EXT ./app
# run: |
# env GOOS=${{ matrix.OS }} GOARCH=${{ matrix.ARCH }} go build -v -o mediarizer2-${{ matrix.ARCH }}-${{ matrix.OS }} ./app
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: mediarizer2-${{ matrix.ARCH }}-${{ matrix.OS }}
path: mediarizer2-${{ matrix.ARCH }}-${{ matrix.OS }}
release:
needs: build
runs-on: ubuntu-latest
# if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- 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)
if [ -z "$LATEST_TAG" ]; 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