Skip to content

Merge pull request #1309 from Lazin3ss/development #132

Merge pull request #1309 from Lazin3ss/development

Merge pull request #1309 from Lazin3ss/development #132

Workflow file for this run

on:
push:
branches: [ master, main ]
workflow_dispatch:
inputs:
tag:
description: 'Tag for the new release. Use semantic versioning e.g. v1.0.0. Leave empty to only update the nightly build.'
type: string
required: false
default: ''
prerelease:
description: 'Set as a pre-release.'
type: boolean
required: false
default: false
makeLatest:
description: 'Set as the latest release.'
type: boolean
required: false
default: true
draft:
description: 'Set as a draft release.'
type: boolean
required: false
default: false
discussionCategory:
description: 'When provided this will generate a discussion of the specified category, e.g. Announcements.'
type: string
required: false
default: ''
permissions:
checks: write
contents: write
name: releases
jobs:
tag:
name: prepare tag
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
outputs:
version: ${{ env.version }}
buildTime: ${{ env.buildTime }}
#previousTag: ${{ steps.previousTag.outputs.tag }}
steps:
- uses: actions/checkout@v3
#- name: Get previous tag
# id: previousTag
# uses: actions-ecosystem/action-get-latest-tag@v1
# with:
# semver_only: true
- name: Set version
run: |
if [ "${{ github.event.inputs.tag }}" != "" ]; then
echo "version=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
else
echo "version=nightly" >> $GITHUB_ENV
fi
echo "buildTime=$(date '+%Y-%m-%d')" >> $GITHUB_ENV
shell: bash
build:
name: prepare release
if: ${{ github.actor != 'dependabot[bot]' }}
needs: tag
strategy:
matrix:
cfg:
- runner_os: windows
os: windows-2022
goos: windows
goarch: amd64
bin: Ikemen_GO.exe
glibc: ''
target: ''
- runner_os: linux
os: ubuntu-20.04 # ubuntu-22.04 / ubuntu-18.04 (deprecated)
goos: linux
goarch: amd64
bin: Ikemen_GO_Linux
glibc: '2.13'
target: ''
- runner_os: macos
os: macos-11 # macos-10.15 (deprecated)
goos: darwin
goarch: amd64
bin: Ikemen_GO_MacOS
glibc: ''
target: '10.7'
runs-on: ${{ matrix.cfg.os }}
steps:
- uses: actions/checkout@v3
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version: ~1.20
#go-version-file: go.mod
#cache-key-suffix: -ikemen
- name: Install dependencies
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update && sudo apt-get install -y libasound2-dev libgl1-mesa-dev xorg-dev libgtk-3-dev
fi
shell: bash
- name: Build
run: |
ldflags="-X 'main.Version=${{ needs.tag.outputs.version }}' -X 'main.BuildTime=${{ needs.tag.outputs.buildTime }}'"
export GOOS="${{ matrix.cfg.goos }}"
export GOARCH="${{ matrix.cfg.goarch }}"
export CGO_ENABLED=1
if [ "${{ matrix.cfg.glibc }}" != "" ]; then
wget https://raw.githubusercontent.com/wheybags/glibc_version_header/master/version_headers/x64/force_link_glibc_${{ matrix.cfg.glibc }}.h -O $PWD/force_link_glibc.h
export CGO_CFLAGS="$CGO_CFLAGS -include $PWD/force_link_glibc.h"
export CGO_CXXFLAGS="$CGO_CXXFLAGS -include $PWD/force_link_glibc.h"
fi
if [ "$RUNNER_OS" == "macOS" ]; then
export CGO_LDFLAGS="$CGO_LDFLAGS -mmacosx-version-min=${{ matrix.cfg.target }}"
export CGO_CFLAGS="$CGO_CFLAGS -mmacosx-version-min=${{ matrix.cfg.target }}"
export CGO_CXXFLAGS="$CGO_CXXFLAGS -mmacosx-version-min=${{ matrix.cfg.target }}"
elif [ "$RUNNER_OS" == "Windows" ]; then
ldflags="$ldflags -H windowsgui"
cd windres
windres -o ../src/ikemen_go.syso Ikemen_GO.rc
cd ..
fi
echo "ldflags: $ldflags"
echo "CGO_LDFLAGS: $CGO_LDFLAGS"
echo "CGO_CFLAGS: $CGO_CFLAGS"
echo "CGO_CXXFLAGS: $CGO_CXXFLAGS"
go env -w GO111MODULE=on
go mod download
go build -v -ldflags "$ldflags" -o ./${{ matrix.cfg.bin }} ./src
if [ "$RUNNER_OS" != "Windows" ]; then
chmod +x ${{ matrix.cfg.bin }}
fi
shell: bash
- name: Prepare artifacts
id: artifacts
run: |
echo "Preparing files for deployment"
mkdir deploy
cp ${{ matrix.cfg.bin }} deploy/
git clone https://github.com/ikemen-engine/Ikemen_GO-Elecbyte-Screenpack.git
cp -r data external font Ikemen_GO-Elecbyte-Screenpack/chars Ikemen_GO-Elecbyte-Screenpack/data Ikemen_GO-Elecbyte-Screenpack/font Ikemen_GO-Elecbyte-Screenpack/stages deploy/
cp License.txt deploy/
cp Ikemen_GO-Elecbyte-Screenpack/LICENCE.txt deploy/ScreenpackLicense.txt
echo "Zipping deploy directory"
cd deploy
if [ "${{ github.event.inputs.tag }}" == "" ]; then
ARTIFACT_NAME=Ikemen_GO-dev-${{ matrix.cfg.runner_os }}.zip
echo "artifact=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT"
echo "${{ needs.tag.outputs.buildTime }}" > external/script/version
else
ARTIFACT_NAME=Ikemen_GO-${{ needs.tag.outputs.version }}-${{ matrix.cfg.runner_os }}.zip
echo "artifact=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT"
echo "${{ needs.tag.outputs.version }}" > external/script/version
fi
if [ "$RUNNER_OS" == "Windows" ]; then
"/c/Program Files/7-Zip/7z.exe" a ../$ARTIFACT_NAME *
else
cp ../build/Ikemen_GO.command .
zip -r ../$ARTIFACT_NAME *
fi
echo "Successfully prepared assets for deployment"
shell: bash
- name: Update dev release
if: "${{ github.event.inputs.tag == '' }}"
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.IKEMEN_TOKEN }}
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "${{ steps.artifacts.outputs.artifact }}"
body: |
The nightly release, or more precisely, the latest development version, is generated after each commit and always represents the most up-to-date iteration of the source code. It features the newest development version of the engine and screenpack files, making it ready for testing straightaway. Using it can eliminate the need to compile the source code for the latest, cutting-edge updates. However, as a consequence, it may sometimes contain regressions that were not yet discovered and/or outpace the documentation that corresponds to stable releases with version numbers like v x.x.x.
discussionCategory: ""
draft: false
generateReleaseNotes: false
makeLatest: false
name: nightly
omitBody: false
omitBodyDuringUpdate: false
omitDraftDuringUpdate: true
omitName: false
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
prerelease: true
removeArtifacts: false
replacesArtifacts: true
skipIfReleaseExists: false
tag: nightly
updateOnlyUnreleased: false
- name: Create Release
if: "${{ github.event.inputs.tag != '' }}"
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.IKEMEN_TOKEN }}
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "${{ steps.artifacts.outputs.artifact }}"
# body: |
# ${{ needs.tag.outputs.changelog }}
discussionCategory: ${{ github.event.inputs.discussionCategory }}
draft: ${{ github.event.inputs.draft }}
generateReleaseNotes: true
makeLatest: ${{ github.event.inputs.makeLatest }}
name: ${{ needs.tag.outputs.version }}
omitBody: false
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitName: false
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
prerelease: ${{ github.event.inputs.prerelease }}
removeArtifacts: false
replacesArtifacts: true
skipIfReleaseExists: false
tag: ${{ needs.tag.outputs.version }}
updateOnlyUnreleased: false