ci: fix scoop manifest creation that prevented releasing #322
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
env: | |
Revision: ${{ github.run_number }} | |
GITHUB_REF: "${{ github.ref }}" | |
NSIS_ROOT: "C:/Program Files (x86)/NSIS" | |
RELEASE_DIR: artifacts | |
WINDOWS_TARGET: x86_64-pc-windows-msvc | |
LINUX_TARGET: x86_64-unknown-linux-gnu | |
RELEASE_BIN: hc | |
PROJECT_NAME: hc | |
RELEASER_VER: 0.11.2 | |
CI_BUILD_NUMBER: ${{ github.run_number }} | |
on: | |
push: | |
branches: [ master ] | |
tags: | |
- "v*" # Run when tag matches v*, i.e. v1.0, v20.15.10 | |
pull_request: | |
branches: [ master ] | |
workflow_dispatch: | |
jobs: | |
prepare: | |
name: Preparation | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.get_version.outputs.VERSION }} | |
steps: | |
- name: Query version number | |
id: get_version | |
shell: bash | |
run: | | |
echo "using version tag ${GITHUB_REF:11}" | |
echo "version=${GITHUB_REF:11}" >> $GITHUB_OUTPUT | |
windows_build: | |
name: Windows Build | |
needs: [ prepare ] | |
runs-on: [self-hosted, windows, x64] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Add msbuild to PATH | |
uses: microsoft/setup-msbuild@v2 | |
with: | |
msbuild-architecture: x64 | |
vs-version: '17.8' | |
- name: Check third party libs existence | |
id: check_files | |
uses: andstor/file-existence-action@v3 | |
with: | |
files: "c:/external_lib/apr/lib/apr-1.lib" | |
- name: Copy third party libs | |
if: steps.check_files.outputs.files_exists == 'true' | |
run: | | |
mkdir external_lib | |
xcopy c:\external_lib external_lib /S /Y | |
- name: Get third party libs | |
if: steps.check_files.outputs.files_exists != 'true' | |
run: | | |
Invoke-WebRequest -Uri https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-win32bin-2.5.0.zip -OutFile expat-win32bin-2.5.0.zip | |
Invoke-WebRequest -Uri https://dlcdn.apache.org/apr/apr-1.7.4-win32-src.zip -OutFile apr-1.7.4-win32-src.zip | |
Invoke-WebRequest -Uri https://dlcdn.apache.org/apr/apr-util-1.6.3-win32-src.zip -OutFile apr-util-1.6.3-win32-src.zip | |
Invoke-WebRequest -Uri https://github.com/openssl/openssl/archive/refs/tags/openssl-3.2.1.zip -OutFile openssl-3.2.1.zip | |
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/expat-win32bin-2.5.0.zip", "$PWD/Expat") | |
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/apr-1.7.4-win32-src.zip", "$PWD") | |
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/apr-util-1.6.3-win32-src.zip", "$PWD") | |
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/openssl-3.2.1.zip", "$PWD") | |
- uses: ilammy/msvc-dev-cmd@v1 | |
- name: Build third party libs | |
if: steps.check_files.outputs.files_exists != 'true' | |
shell: cmd | |
env: | |
LINK: /cgthreads:8 | |
run: | | |
cd ./openssl-openssl-3.2.1/ | |
perl Configure VC-WIN64A -static --prefix=${{ github.workspace }}/external_lib/openssl --openssldir=${{ github.workspace }}/external_lib/ssl | |
nmake | |
nmake install_sw | |
cd ../Expat/Source/ | |
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/external_lib/expat" -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_FLAGS_RELEASE="/MP /MT /Ox /Ob2 /Oy /Oi /Ot /GL /Qpar /Zc:wchar_t /Zc:inline /Zc:preprocessor /validate-charset /D NDEBUG" . | |
nmake install | |
cd ../../apr-1.7.4/ | |
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/external_lib/apr" -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_FLAGS_RELEASE="/MP /MT /Ox /Ob2 /Oy /Oi /Ot /GL /Qpar /Zc:wchar_t /Zc:inline /Zc:preprocessor /validate-charset /D NDEBUG" . | |
nmake install | |
cd ../apr-util-1.6.3/ | |
set CMAKE_LIBRARY_PATH=${{ github.workspace }}/external_lib/apr/lib;${{ github.workspace }}/external_lib/expat/lib | |
set CMAKE_INCLUDE_PATH=${{ github.workspace }}/external_lib/apr/include;${{ github.workspace }}/external_lib/expat/include | |
set OPENSSL_ROOT_DIR=${{ github.workspace }}/external_lib/openssl | |
set OPENSSL_LIBRARIES=${{ github.workspace }}/external_lib/openssl/lib | |
set OPENSSL_INCLUDE_DIR=${{ github.workspace }}/external_lib/openssl/include/openssl | |
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/external_lib/apr" -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_FLAGS_RELEASE="/MP /MT /Ox /Ob2 /Oy /Oi /Ot /GL /Qpar /Zc:wchar_t /Zc:inline /Zc:preprocessor /validate-charset /D NDEBUG" . | |
nmake install | |
cd .. | |
mkdir c:\external_lib | |
xcopy external_lib c:\external_lib /S /Y | |
- run: nuget restore src\linq2hash.sln | |
- name: Build | |
working-directory: src | |
shell: cmd | |
env: | |
PROJECT_BASE_PATH: "${{runner.workspace}}\\${{ env.PROJECT_NAME }}\\src" | |
BINPLACE_PLACEFILE: "${{runner.workspace}}\\${{ env.PROJECT_NAME }}\\binplace.txt" | |
HC_TEST_DIR: "${{runner.workspace}}\\${{ env.PROJECT_NAME }}\\_tst.net" | |
RUNNER_CONTEXT: ${{ toJSON(runner) }} | |
PROGRAM_VERSION: ${{ needs.prepare.outputs.version }} | |
APR_HOME16: "${{runner.workspace}}\\${{ env.PROJECT_NAME }}\\external_lib" | |
run: | | |
echo "$RUNNER_CONTEXT" | |
msbuild hc.xml | |
- name: Packaging | |
if: endsWith(github.ref, 'merge') == false | |
env: | |
PROJECT_BASE_PATH: "${{runner.workspace}}\\${{ env.PROJECT_NAME }}\\src" | |
PKG_PATH: pkg | |
run: | | |
mkdir ${{ env.RELEASE_DIR }} | |
xcopy ${{ env.PROJECT_BASE_PATH }}\Install\Release ${{ env.RELEASE_DIR }}\* /S /Y | |
mkdir ${{ env.PROJECT_BASE_PATH }}\${{ env.PKG_PATH }} | |
xcopy ${{ env.PROJECT_BASE_PATH }}\x64\Release\ru ${{ env.PROJECT_BASE_PATH }}\${{ env.PKG_PATH }}\ru\* /S /Y | |
xcopy ${{ env.PROJECT_BASE_PATH }}\Binplace-x64\Release\${{ env.RELEASE_BIN }}.exe ${{ env.PROJECT_BASE_PATH }}\${{ env.PKG_PATH }} /S /Y | |
tar -cvzf .\${{ env.RELEASE_DIR }}\${{ env.RELEASE_BIN }}-${{ needs.prepare.outputs.version }}-${{ env.WINDOWS_TARGET }}.tar.gz -C ${{ env.PROJECT_BASE_PATH }}\${{ env.PKG_PATH }} * | |
- uses: actions/upload-artifact@v3 | |
if: endsWith(github.ref, 'merge') == false | |
with: | |
name: windows | |
path: ./${{ env.RELEASE_DIR }} | |
linux_build: | |
name: Linux Build | |
needs: [ prepare ] | |
runs-on: [self-hosted, linux, x64] | |
strategy: | |
matrix: | |
target: [ x86_64-linux-gnu ] | |
include: | |
- target: x86_64-linux-gnu | |
abi: gnu | |
os: linux | |
arch: x86_64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Zig | |
uses: goto-bus-stop/setup-zig@v2 | |
with: | |
version: 0.11.0 | |
- name: Build | |
run: | | |
chmod +x ./linux_build.sh | |
./linux_build.sh ${{ matrix.abi }} ${{ matrix.os }} ${{ matrix.arch }} | |
env: | |
HC_VERSION: ${{ needs.prepare.outputs.version }} | |
- name: Create artifact directory | |
run: mkdir ${{ env.RELEASE_DIR }} | |
- name: Packaging | |
if: endsWith(github.ref, 'merge') == false | |
run: cp -v ./bin/*.gz ./${{ env.RELEASE_DIR }}/ | |
- uses: actions/upload-artifact@v3 | |
if: endsWith(github.ref, 'merge') == false | |
with: | |
name: ${{ matrix.os }}_${{ matrix.abi }}_${{ matrix.arch }} | |
path: ./${{ env.RELEASE_DIR }} | |
generate-changelog: | |
name: Generate changelog | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
outputs: | |
release_body: ${{ steps.git-cliff.outputs.content }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Generate a changelog | |
uses: orhun/git-cliff-action@main | |
id: git-cliff | |
with: | |
config: cliff.toml | |
args: -vv --latest --strip header | |
env: | |
OUTPUT: CHANGES.md | |
release: | |
name: GitHub Release | |
needs: [ windows_build, linux_build, generate-changelog ] | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Query version number | |
id: get_version | |
shell: bash | |
run: | | |
echo "using version tag ${GITHUB_REF:11}" | |
echo "version=${GITHUB_REF:11}" >> $GITHUB_OUTPUT | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_version.outputs.VERSION }} | |
release_name: ${{ steps.get_version.outputs.VERSION }} | |
body: "${{ needs.generate-changelog.outputs.release_body }}" | |
- name: Download Windows zip | |
uses: actions/download-artifact@v3 | |
with: | |
name: windows | |
path: windows | |
- name: Download Linux x86_64 GNU tarball | |
uses: actions/download-artifact@v3 | |
with: | |
name: linux_gnu_x86_64 | |
path: linux_gnu_x86_64 | |
- name: Create fake Cargo.toml | |
run: | | |
cat >Cargo.toml <<EOL | |
[package] | |
name = "${{ env.RELEASE_BIN }}" | |
version = "${{ steps.get_version.outputs.VERSION }}" | |
description = "Hash Calculator is the console tool that can calculate about 50 cryptographic hashes of strings and files." | |
authors = ["egoroff <egoroff@gmail.com>"] | |
homepage = "https://github.com/aegoroff/hc" | |
license = "LGPL-3.0" | |
EOL | |
- name: Download Releaser | |
run: | | |
curl -L -o releaser.tar.gz https://github.com/aegoroff/releaser/releases/download/${{ env.RELEASER_VER }}/releaser-${{ env.RELEASER_VER }}-x86_64-unknown-linux-musl.tar.gz | |
tar -xf releaser.tar.gz | |
- name: Create scoop json | |
run: ${{ github.workspace }}/releaser s -c . -b https://github.com/${{ github.repository }}/releases/download/${{ steps.get_version.outputs.VERSION }}/ -i './windows/' -e ${{ env.RELEASE_BIN }}.exe -u ${{ env.RELEASE_BIN }}.json | |
- name: Publish scoop json | |
uses: dmnemec/copy_file_to_another_repo_action@main | |
env: | |
API_TOKEN_GITHUB: ${{ secrets.GH_TOKEN }} | |
with: | |
github_server: 'github.com' | |
source_file: ${{ env.RELEASE_BIN }}.json | |
destination_repo: 'aegoroff/scoop-bucket' | |
user_email: 'egoroff@email.com' | |
user_name: 'aegoroff' | |
commit_message: "release: ${{ steps.get_version.outputs.VERSION }}" | |
- name: Release Windows tarball | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./windows/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.WINDOWS_TARGET }}.tar.gz | |
asset_content_type: application/gzip | |
asset_name: ${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.WINDOWS_TARGET }}.tar.gz | |
- name: Release Windows installer | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./windows/${{ env.RELEASE_BIN }}.setup.${{ steps.get_version.outputs.VERSION }}.${{ env.Revision }}.exe | |
asset_content_type: application/exe | |
asset_name: ${{ env.RELEASE_BIN }}.setup.${{ steps.get_version.outputs.VERSION }}.${{ env.Revision }}.exe | |
- name: Release x86_64 Linux GNU tarball | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./linux_gnu_x86_64/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.LINUX_TARGET }}.tar.gz | |
asset_content_type: application/gzip | |
asset_name: ${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.LINUX_TARGET }}.tar.gz |