Skip to content

Commit

Permalink
ci: prepare job to upload rockspec
Browse files Browse the repository at this point in the history
  • Loading branch information
luau-project committed Nov 10, 2024
1 parent 1008b29 commit 36b689f
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 36 deletions.
78 changes: 67 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: |
if ("${{ github.repository }}" -eq "luau-project/lua-uuid" -and "${{ github.ref_name }}" -eq "main" -and "${{ github.ref }}" -eq "refs/tags/v${{ env.ROCKSPEC_VERSION }}")
{
Add-Content "${{ github.env }}" "ROCKSPEC=lua-uuid-${{ env.ROCKSPEC_VERSION }}-1.rockspec";
Add-Content "${{ github.env }}" "ROCKSPEC=lua-uuid-${{ env.ROCKSPEC_VERSION }}-0.rockspec";
}
else
{
Expand Down Expand Up @@ -129,15 +129,6 @@ jobs:
LUA_INTERPRETER: /${{ matrix.MSYS2_CONFIG.sys }}/bin/${{ matrix.Lua.msys2_lua_interpreter }}

steps:

- name: Set environment variable to hold the rockspec name
run: |
if [[ "${{ github.repository }}" == "luau-project/lua-uuid" ]] && [[ "${{ github.ref_name }}" == "main" ]] && [[ "${{ github.ref }}" == "refs/tags/v${{ env.ROCKSPEC_VERSION }}" ]];
then
echo "ROCKSPEC=lua-uuid-${{ env.ROCKSPEC_VERSION }}-1.rockspec" >> "${{ github.env }}";
else
echo "ROCKSPEC=${{ env.DEV_ROCKSPEC }}" >> "${{ github.env }}";
fi;

- name: Setup MSYS2
uses: msys2/setup-msys2@v2
Expand All @@ -150,6 +141,15 @@ jobs:
mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-${{ matrix.Lua.msys2_pkg_name }}
mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-lua-luarocks
- name: Set environment variable to hold the rockspec name
run: |
if [[ "${{ github.repository }}" == "luau-project/lua-uuid" ]] && [[ "${{ github.ref_name }}" == "main" ]] && [[ "${{ github.ref }}" == "refs/tags/v${{ env.ROCKSPEC_VERSION }}" ]];
then
echo "ROCKSPEC=lua-uuid-${{ env.ROCKSPEC_VERSION }}-0.rockspec" >> "${{ github.env }}";
else
echo "ROCKSPEC=${{ env.DEV_ROCKSPEC }}" >> "${{ github.env }}";
fi;
- name: Configure LuaRocks
run: |
source /etc/makepkg_mingw.conf
Expand Down Expand Up @@ -180,4 +180,60 @@ jobs:
${{ env.LUA_INTERPRETER }} $sample;
done;
upload-rockspec:
name: Upload rockspec
runs-on: ubuntu-latest
if: ${{ github.repository == 'luau-project/lua-uuid' && github.ref_name == 'main' && startsWith(github.ref, 'refs/tags/') }}
needs:
- build
- msys2-build

defaults:
run:
shell: pwsh

steps:

- name: Set environment variable to hold the rockspec name
run: |
if ("${{ github.repository }}" -eq "luau-project/lua-uuid" -and "${{ github.ref_name }}" -eq "main" -and "${{ github.ref }}" -eq "refs/tags/v${{ env.ROCKSPEC_VERSION }}")
{
Add-Content "${{ github.env }}" "ROCKSPEC=lua-uuid-${{ env.ROCKSPEC_VERSION }}-0.rockspec";
}
else
{
Add-Content "${{ github.env }}" "ROCKSPEC=${{ env.DEV_ROCKSPEC }}";
}
- name: Checkout
uses: actions/checkout@v4
with:
path: lua-uuid

- name: Install libuuid-dev
run: sudo apt install -y uuid-dev

- name: Setup Lua
uses: luarocks/gh-actions-lua@v10

- name: Setup LuaRocks
uses: luarocks/gh-actions-luarocks@v5

- name: Install dependencies
run: luarocks install dkjson
working-directory: lua-uuid

- name: Upload rockspec to LuaRocks
working-directory: lua-uuid
env:
UPLOAD_KEY: ${{ secrets.LUAROCKS_APIKEY }}
run: |
$rockspec = Get-ChildItem . -Recurse -File |
Where-Object Name -EQ "${{ env.ROCKSPEC }}" |
Select-Object -ExpandProperty FullName -First 1;
$color = (0x1b -as [char]) + "[36m";
Write-Host "Uploading rockspec: ${color}${rockspec}";
luarocks upload $rockspec "--api-key=$env:UPLOAD_KEY" --skip-pack
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

**lua-uuid** is a lightweight, native library for Lua (5.1 and newer) to deal with Universally Unique Id (UUID).

* On Linux and Cygwin, it uses ```libuuid``` to generate UUIDs;
* On Linux, it uses ```libuuid``` to generate UUIDs;
* On Windows, it uses the WINAPI ```rpcrt4``` library;
* On MacOS / iOS, it uses the ```CoreFoundation``` framework.

Expand All @@ -18,14 +18,13 @@
* [Parse GUIDs / UUIDs from string](#parse-guids--uuids-from-string)
* [Compare GUIDs / UUIDs](#compare-guids--uuids)
* [Verify GUIDs / UUIDs nullity](#verify-guids--uuids-nullity)
* [Remarks](#remarks)
* [Future works](#future-works)

## Installation

> [!IMPORTANT]
>
> On Linux and Cygwin, ```lua-uuid``` depends on ```libuuid```:
> On Linux, ```lua-uuid``` depends on ```libuuid```:
>
> * On Debian-based distributions:
>
Expand All @@ -38,8 +37,6 @@
> ```bash
> sudo dnf install libuuid-devel
> ```
>
> * On Cygwin, install ```libuuid-devel```.
Assuming that [LuaRocks](https://luarocks.org/) is properly installed and configured on your system, execute the following command:

Expand Down Expand Up @@ -144,10 +141,6 @@ local id3 = uuid.parse("00000000-0000-0000-0000-000000000000")
print(id3:isnil())
```

## Remarks

Note to Cygwin users: Ideally, Cygwin should be using the WINAPI part. However, since LuaRocks does not handle Cygwin as Windows by default, we opted to leave Cygwin as a Linux variant for now.

## Future works

* Add CMake as build system
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package = "lua-uuid"
version = "0.0.1-1"
version = "0.0.1-0"

source = {
url = "git://github.com/luau-project/lua-uuid.git",
Expand All @@ -8,7 +8,15 @@ source = {

description = {
homepage = "https://github.com/luau-project/lua-uuid",
summary = [[Lightweight, native GUID / UUID library for Lua]],
summary = [[Lightweight, native GUID / UUID library for Lua]],,
detailed = [=[
lua-uuid is a lightweight, native library for Lua (5.1 and newer) to deal with Universally Unique Id (UUID).
* On Linux, it uses libuuid to generate UUIDs;
* On Windows, it uses the WINAPI rpcrt4 library;
* On MacOS / iOS, it uses the CoreFoundation framework.
Visit the GitHub repository for more information.]=],
license = "MIT"
}

Expand All @@ -24,17 +32,12 @@ external_dependencies = {
["UUID"] = {
header = "uuid/uuid.h"
}
},
cygwin = {
["UUID"] = {
header = "uuid/uuid.h"
}
}
}
}

local function make_plat(plat)
if (plat == "linux" or plat == "cygwin") then
if (plat == "linux") then
return {
type = "builtin",
modules = {
Expand All @@ -47,7 +50,7 @@ local function make_plat(plat)
}
}
}
elseif (plat == "win32" or plat == "mingw") then
elseif (plat == "win32" or plat == "mingw" or plat == "cygwin") then
return {
type = "builtin",
modules = {
Expand Down
17 changes: 10 additions & 7 deletions rockspecs/lua-uuid-dev-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ source = {
description = {
homepage = "https://github.com/luau-project/lua-uuid",
summary = [[Lightweight, native GUID / UUID library for Lua]],
detailed = [=[
lua-uuid is a lightweight, native library for Lua (5.1 and newer) to deal with Universally Unique Id (UUID).
* On Linux, it uses libuuid to generate UUIDs;
* On Windows, it uses the WINAPI rpcrt4 library;
* On MacOS / iOS, it uses the CoreFoundation framework.
Visit the GitHub repository for more information.]=],
license = "MIT"
}

Expand All @@ -23,17 +31,12 @@ external_dependencies = {
["UUID"] = {
header = "uuid/uuid.h"
}
},
cygwin = {
["UUID"] = {
header = "uuid/uuid.h"
}
}
}
}

local function make_plat(plat)
if (plat == "linux" or plat == "cygwin") then
if (plat == "linux") then
return {
type = "builtin",
modules = {
Expand All @@ -46,7 +49,7 @@ local function make_plat(plat)
}
}
}
elseif (plat == "win32" or plat == "mingw") then
elseif (plat == "win32" or plat == "mingw" or plat == "cygwin") then
return {
type = "builtin",
modules = {
Expand Down

0 comments on commit 36b689f

Please sign in to comment.