Skip to content

improve tips

improve tips #13663

Workflow file for this run

name: Windows
on:
pull_request:
push:
release:
types: [published]
jobs:
build:
strategy:
matrix:
os: [windows-2019, windows-2022]
arch: [x64, x86]
runs-on: ${{ matrix.os }}
concurrency:
group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.os }}-${{ matrix.arch }}-Windows
cancel-in-progress: true
steps:
- uses: actions/checkout@v2
with:
# WyriHaximus/github-action-get-previous-tag@master need it
fetch-depth: 0
submodules: true
- uses: xmake-io/github-action-setup-xmake@v1
with:
# this is not supported, use dev branch instead
# xmake-version: local#
xmake-version: branch@dev
- uses: dlang-community/setup-dlang@v1
with:
compiler: dmd-latest
- uses: little-core-labs/get-git-tag@v3.0.2
id: tagName
# Force xmake to a specific folder (for cache)
- name: Set xmake package cache path
run: echo "XMAKE_PKG_CACHEDIR=$(pwd)/xmake-cache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# Cache xmake dependencies
- name: Retrieve xmake cache for packages
uses: actions/cache@v2
with:
path: xmake-cache
key: ${{ matrix.os }}-${{ matrix.arch }}
- name: Set release arch name
run: |
if ("${{ matrix.arch }}" -eq "x64") {
Write-Output "RELEASE_NAME=win64" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append
} else {
Write-Output "RELEASE_NAME=win32" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append
}
- name: Build
run: |
cd core
xmake f -vD -a ${{ matrix.arch }} --embed=y -c
xmake
xmake l os.cp build/xmake.exe ../artifacts/${{env.RELEASE_NAME}}/xmake-bundle.exe
xmake f -vD -a ${{ matrix.arch }} -c
xmake -vD
cd ..
- name: Artifact
run: |
cd core
xrepo update-repo
xmake pack -vD -y --formats=nsis,zip --autobuild=n -o ../artifacts/${{env.RELEASE_NAME}} --basename=xmake xmake
(Get-FileHash ../artifacts/${{env.RELEASE_NAME}}/xmake.zip -Algorithm SHA256).Hash.ToLower() + " *xmake.zip`n" | Out-File ./shafile -Encoding ASCII -NoNewLine -Append
Copy-Item shafile ../artifacts/${{env.RELEASE_NAME}}
cd ..
- name: Tests
run: |
Copy-Item ./core/build/xmake.exe ./xmake
Copy-Item ./scripts/xrepo.bat ./xmake
Copy-Item ./scripts/xrepo.ps1 ./xmake
$Env:XMAKE_MAIN_REPO = "https://github.com/xmake-io/xmake-repo.git"
$Env:XMAKE_PROGRAM_DIR = $(Resolve-Path ./xmake)
Set-Item -Path Env:Path -Value ($Env:XMAKE_PROGRAM_DIR + ";" + $Env:Path)
xrepo --version
xmake show
xmake lua -v -D tests/run.lua
# upload artifacts
- name: Upload artifacts (exe)
if: matrix.os == 'windows-2022'
uses: actions/upload-artifact@v4
with:
name: xmake-latest.${{env.RELEASE_NAME}}.exe
path: artifacts/${{env.RELEASE_NAME}}/xmake.exe
- name: Upload artifacts (zip)
if: matrix.os == 'windows-2022'
uses: actions/upload-artifact@v4
with:
name: xmake-latest.${{ env.RELEASE_NAME }}.zip
path: artifacts/${{env.RELEASE_NAME}}/xmake.zip
- name: Upload artifacts (sha256)
if: matrix.os == 'windows-2022'
uses: actions/upload-artifact@v4
with:
name: xmake-latest.${{ env.RELEASE_NAME }}.sha256
path: artifacts/${{env.RELEASE_NAME}}/shafile
- name: Upload artifacts (bundle)
if: matrix.os == 'windows-2022'
uses: actions/upload-artifact@v4
with:
name: xmake-bundle-latest.${{env.RELEASE_NAME}}.exe
path: artifacts/${{env.RELEASE_NAME}}/xmake-bundle.exe
# upload artifacts to latest release
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v3.x
- name: Get Previous tag
id: previoustag
uses: WyriHaximus/github-action-get-previous-tag@master
- name: Upload artifacts to lastest release
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev') && matrix.os == 'windows-2022'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/${{env.RELEASE_NAME}}/xmake.exe
asset_name: xmake-${{ env.GITHUB_REF_SLUG }}.${{ env.RELEASE_NAME }}.exe
tag: ${{ steps.previoustag.outputs.tag }}
overwrite: true
- name: Upload artifacts to lastest release
if: github.ref == 'refs/heads/master' && matrix.os == 'windows-2022'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/${{env.RELEASE_NAME}}/xmake.zip
asset_name: xmake-${{ env.GITHUB_REF_SLUG }}.${{ env.RELEASE_NAME }}.zip
tag: ${{ steps.previoustag.outputs.tag }}
overwrite: true
# publish release
- name: Publish
if: github.event.action == 'published' && matrix.os == 'windows-2022'
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: artifacts/${{env.RELEASE_NAME}}/xmake.exe
asset_name: xmake-${{ steps.tagName.outputs.tag }}.${{ env.RELEASE_NAME }}.exe
asset_content_type: application/zip
- name: Publish
if: github.event.action == 'published' && matrix.os == 'windows-2022'
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: artifacts/${{env.RELEASE_NAME}}/xmake.zip
asset_name: xmake-${{ steps.tagName.outputs.tag }}.${{ env.RELEASE_NAME }}.zip
asset_content_type: application/zip
- name: Publish
if: github.event.action == 'published' && matrix.os == 'windows-2022'
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: artifacts/${{env.RELEASE_NAME}}/shafile
asset_name: xmake-${{ steps.tagName.outputs.tag }}.${{ env.RELEASE_NAME }}.sha256
asset_content_type: application/zip
- name: Publish
if: github.event.action == 'published' && matrix.os == 'windows-2022'
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: artifacts/${{env.RELEASE_NAME}}/xmake-bundle.exe
asset_name: xmake-bundle-${{ steps.tagName.outputs.tag }}.${{ env.RELEASE_NAME }}.exe
asset_content_type: application/zip