Skip to content

Use a non-deprecated version of upload-artifact. #202

Use a non-deprecated version of upload-artifact.

Use a non-deprecated version of upload-artifact. #202

Workflow file for this run

name: Build
on:
push:
branches: [ master ]
tags: [ 'v*' ]
pull_request:
branches: [ master ]
permissions:
contents: write
jobs:
build:
strategy:
matrix:
os:
- name: ubuntu
version: latest
- name: windows
version: latest
- name: macos
version: latest
runs-on: ${{ matrix.os.name }}-${{ matrix.os.version }}
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
if: matrix.os.name == 'ubuntu'
run: |
sudo apt-get update -y -qq
sudo apt-get install libsdl2-dev libgtk-3-dev gtksourceview-3.0 libao-dev libopenal-dev
- name: Make
run: make -j4 -C bsnes local=false
- name: Upload
uses: actions/upload-artifact@v4
with:
name: bsnes-${{ matrix.os.name }}
path: bsnes/out/bsnes*
release:
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
# Prevent multiple conflicting release jobs from running at once.
concurrency: release-${{ github.ref == 'refs/heads/master' && 'nightly' || github.ref }}
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
with:
path: 'src'
- name: Download Artifacts
uses: actions/[email protected]
with:
path: 'bin'
- name: Package Artifacts
run: |
set -eu
case ${GITHUB_REF} in
refs/tags/*) suffix="-${GITHUB_REF#refs/tags/}" ;;
refs/heads/master) suffix="-nightly" ;;
*) suffix="" ;;
esac
srcdir="${GITHUB_WORKSPACE}/src"
bindir="${GITHUB_WORKSPACE}/bin"
# Hack: Workaround for GitHub artifacts losing attributes.
for program in bsnes
do
chmod +x ${bindir}/${program}-ubuntu/${program}
chmod +x ${bindir}/${program}-macos/${program}.app/Contents/MacOS/${program}
done
for os in ubuntu windows macos
do
mkdir "${os}"
cd "${os}"
# Package bsnes.
outdir=bsnes${suffix}
mkdir ${outdir}
mkdir ${outdir}/Database
mkdir ${outdir}/Firmware
cp -ar ${bindir}/bsnes-${os}/* ${outdir}
cp -a ${srcdir}/bsnes/Database/* ${outdir}/Database
cp -a ${srcdir}/shaders ${outdir}/Shaders
cp -a ${srcdir}/GPLv3.txt ${outdir}
cp -a ${srcdir}/extras/* ${outdir}
zip -r ../bsnes-${os}.zip ${outdir}
cd -
done
- name: Calculate release info
id: relinfo
run: |
echo "datetime=$(date -u +"%Y-%m-%d %T %Z")" >> $GITHUB_OUTPUT
echo "date=$(date +"%Y-%m-%d")" >> $GITHUB_OUTPUT
- name: Delete old nightly release
uses: actions/github-script@v7
id: release
if: ${{!startsWith(github.ref, 'refs/tags/')}}
with:
retries: 3
script: |
const {owner, repo} = context.repo;
try {
const release = await github.rest.repos.getReleaseByTag({owner, repo, tag: "nightly"});
if (release && release.status === 200) {
await github.rest.repos.deleteRelease({owner, repo, release_id: release.data.id});
}
} catch (e) {
console.log(`error deleting old release: ${e}`);
}
try {
await github.rest.git.deleteRef({owner, repo, ref: "tags/nightly"});
} catch (e) {
console.log(`error trying to delete ref: ${e}`);
}
await github.rest.git.createTag({
owner,
repo,
tag: "nightly",
message: "nightly release",
object: context.sha,
type: "commit",
})
- name: Create nightly release
uses: softprops/action-gh-release@v1
if: ${{!startsWith(github.ref, 'refs/tags/')}}
with:
tag_name: nightly
name: bsnes nightly ${{steps.relinfo.outputs.date}}
body: Auto-generated nightly release on ${{steps.relinfo.outputs.datetime}}
files: bsnes*.zip
prerelease: true
- name: Create version release
uses: softprops/action-gh-release@v1
if: ${{startsWith(github.ref, 'refs/tags/')}}
with:
name: bsnes ${{github.ref_name}}
body: This is bsnes ${{github.ref_name}}, released on ${{steps.relinfo.outputs.date}}.
files: bsnes*.zip