s1x-client/.github/workflows/build.yml
Maurice Heumann 0e3e2d5516 Fix workflow
2021-04-07 09:24:06 +02:00

217 lines
7.4 KiB
YAML

name: Build
on:
push:
branches:
- "*"
pull_request:
branches:
- master
types: [closed, opened, synchronize, reopened]
jobs:
modify:
runs-on: ubuntu-latest
name: Apply Git modifications if any are necessary
steps:
- name: Check out files
uses: actions/checkout@v2
with:
submodules: false
lfs: false
# Set up committer info and GPG key
- name: Import GPG key
if: github.event.pull_request.merged
id: import_gpg
uses: XLabsProject/ghaction-import-gpg@25d9d6ab99eb355c169c33c2306a72df85d9f516
with:
git-commit-gpgsign: true
git-committer-email: "${{ secrets.XLABS_CI_EMAIL }}"
git-committer-name: "${{ secrets.XLABS_CI_NAME }}"
git-push-gpgsign: false
git-tag-gpgsign: true
git-user-signingkey: true
gpg-private-key: ${{ secrets.XLABS_CI_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.XLABS_CI_GPG_PASSWORD }}
- name: Extract version from changelog
if: github.event.pull_request.merged
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_depth: 10
path: ./CHANGELOG.md
- name: Create annotated tag
if: github.event.pull_request.merged
run: |
git tag -a -m "${{ steps.changelog_reader.outputs.changes }}" \
"${{ steps.changelog_reader.outputs.version }}" \
"${{ github.event.pull_request.merge_commit_sha }}"
git push origin --tags
build:
name: Build binaries
runs-on: windows-latest
needs:
- modify
strategy:
matrix:
configuration:
- Debug
- Release
steps:
- name: Check out files
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0
# NOTE - if LFS ever starts getting used during builds, switch this to true!
lfs: false
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
- name: Generate project files
run: tools/premake5 vs2019
- name: Set up problem matching
uses: ammaraskar/msvc-problem-matcher@master
- name: Build ${{matrix.configuration}} binaries
run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:Platform=x64 build/s1x.sln
- name: Upload ${{matrix.configuration}} binaries
uses: actions/upload-artifact@v2
with:
name: ${{matrix.configuration}} binaries
path: |
build/bin/x64/${{matrix.configuration}}/*
- name: Upload ${{matrix.configuration}} debug symbols
uses: actions/upload-artifact@v2
with:
name: ${{matrix.configuration}} debug symbols
path: |
build/bin/**/*.pdb
release:
name: Create new GitHub Release
needs: build
runs-on: ubuntu-latest
if: github.event.pull_request.merged
steps:
- name: Check out files
uses: actions/checkout@v2
with:
submodules: false
lfs: false
- name: Download Release binaries
uses: actions/download-artifact@v2
with:
name: Release binaries
# Set up committer info and GPG key
- name: Import GPG key
id: import_gpg
uses: XLabsProject/ghaction-import-gpg@25d9d6ab99eb355c169c33c2306a72df85d9f516
with:
git-commit-gpgsign: true
git-committer-email: "${{ secrets.XLABS_CI_EMAIL }}"
git-committer-name: "${{ secrets.XLABS_CI_NAME }}"
git-push-gpgsign: false
git-tag-gpgsign: true
git-user-signingkey: true
gpg-private-key: ${{ secrets.XLABS_CI_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.XLABS_CI_GPG_PASSWORD }}
- name: Extract version from changelog
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_depth: 2
path: ./CHANGELOG.md
- uses: papeloto/action-zip@v1
with:
recursive: false
files: s1x.exe
dest: s1x-${{ steps.changelog_reader.outputs.version }}.zip
- name: Sign ZIP file
run: gpg --output "s1x-${{ steps.changelog_reader.outputs.version }}.zip.sig" --detach-sig "s1x-${{ steps.changelog_reader.outputs.version }}.zip"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.XLABS_CI_GITHUB_TOKEN }}
with:
tag_name: ${{ steps.changelog_reader.outputs.version }}
release_name: ${{ steps.changelog_reader.outputs.version }}
body: ${{ steps.changelog_reader.outputs.changes }}
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
prerelease: ${{ steps.changelog_reader.outputs.status == 'prereleased' }}
- name: Upload Release ZIP
id: upload-release-zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.XLABS_CI_GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/s1x-${{ steps.changelog_reader.outputs.version }}.zip
asset_name: s1x-${{ steps.changelog_reader.outputs.version }}.zip
asset_content_type: application/zip
- name: Upload Release ZIP signature
id: upload-release-zip-signature
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.XLABS_CI_GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/s1x-${{ steps.changelog_reader.outputs.version }}.zip.sig
asset_name: s1x-${{ steps.changelog_reader.outputs.version }}.zip.sig
asset_content_type: text/plain
- name: Remove extra files
run: git clean -ffdx && git reset --hard
- name: Create Pull Request to merge master back into develop
uses: peter-evans/create-pull-request@v3
env:
GITHUB_TOKEN: ${{ secrets.XLABS_CI_GITHUB_TOKEN }}
with:
delete-branch: false
author: "${{ secrets.XLABS_CI_NAME }} <${{ secrets.XLABS_CI_EMAIL }}>"
committer: "${{ secrets.XLABS_CI_NAME }} <${{ secrets.XLABS_CI_EMAIL }}>"
branch: release/${{ steps.changelog_reader.outputs.version }}
base: develop
body: |
This Pull Request contains all changes done for the release of ${{ steps.changelog_reader.outputs.version }}, ready to be merged back into `master`.
This release should be merged in due time to make sure that changes done to files such as the changelog as part of the release are also contained on the `develop` branch.
title: Merge ${{ steps.changelog_reader.outputs.version }} into develop
notify:
name: Notify Discord
runs-on: ubuntu-latest
if: |
github.repository_owner == 'XLabsProject' && (
(
github.event.pull_request.merged
) || (
github.event.push.ref == 'refs/heads/master' ||
github.event.push.ref == 'refs/heads/develop'
)
)
steps:
- name: Post CI status notification to Discord
uses: sarisia/actions-status-discord@v1.7.1
if: always()
with:
webhook: ${{ secrets.DISCORD_CI_BOT_WEBHOOK }}
title: "Build"