mirror of
https://github.com/BloopAI/setup-zig.git
synced 2026-08-25 12:38:34 +00:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e24fd328aa | ||
|
|
d77db2eb23 | ||
|
|
ddee6faec6 | ||
|
|
dfa210dd0b | ||
|
|
a64a1dc5e1 | ||
|
|
64c2ecb313 | ||
|
|
869a4299cf | ||
|
|
75b5fc3918 | ||
|
|
7784e301e8 | ||
|
|
9566bb3e87 | ||
|
|
2cffe3f4a2 | ||
|
|
c2eddb6989 | ||
|
|
8cf2a1296e | ||
|
|
1ef867edef | ||
|
|
9f0698fd52 | ||
|
|
bf730ebe84 | ||
|
|
632586c725 | ||
|
|
66631fd873 | ||
|
|
0cee191d07 | ||
|
|
e2ed12d04c | ||
|
|
cfbd20032e | ||
|
|
55609d477b | ||
|
|
d1113581f1 | ||
|
|
8db8d637fe | ||
|
|
942865929d | ||
|
|
8a2fb59d7a | ||
|
|
c34989108a | ||
|
|
8a99a7c9ad | ||
|
|
bcf8978f8e | ||
|
|
8c8dfa672b | ||
|
|
733ad9e5c7 |
8
.github/dependabot.yml
vendored
Normal file
8
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "04:00"
|
||||
open-pull-requests-limit: 10
|
||||
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@@ -15,6 +15,7 @@ jobs:
|
||||
smoke-test:
|
||||
name: Build test
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
zig-version: [0.7.0, 0.8.0, 0.9.0, 0.10.0]
|
||||
@@ -24,7 +25,7 @@ jobs:
|
||||
runs-on: ${{matrix.os}}
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Install Zig
|
||||
uses: goto-bus-stop/setup-zig@default
|
||||
with:
|
||||
|
||||
11
CHANGELOG.md
11
CHANGELOG.md
@@ -4,9 +4,14 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## 1.4.0
|
||||
* The action now caches compilers in your repository's Actions cache by default. This significantly
|
||||
speeds up installs on average. [#53](https://github.com/goto-bus-stop/setup-zig/pull/54)
|
||||
## 2.0.2
|
||||
* Fix tool-cache usage, this should speed up the action if zig was already downloaded before. [#45](https://github.com/goto-bus-stop/setup-zig/pull/45)
|
||||
|
||||
## 2.0.1
|
||||
* Update docs to v2
|
||||
|
||||
## 2.0.0
|
||||
* Change `version` option default to `master`. See [#24](https://github.com/goto-bus-stop/setup-zig/issues/24)
|
||||
|
||||
## 1.3.0
|
||||
* Support pinning to a specific commit of the zig compiler. ([@codehz](https://github.com/codehz) in [#14](https://github.com/goto-bus-stop/setup-zig/pull/14))
|
||||
|
||||
29
README.md
29
README.md
@@ -17,33 +17,28 @@ jobs:
|
||||
runs-on: ${{matrix.os}}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: goto-bus-stop/setup-zig@v1
|
||||
- uses: goto-bus-stop/setup-zig@v2
|
||||
- run: zig build test
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: goto-bus-stop/setup-zig@v1
|
||||
- uses: goto-bus-stop/setup-zig@v2
|
||||
- run: zig fmt --check src/*.zig
|
||||
```
|
||||
|
||||
Optionally set a Zig version:
|
||||
```yaml
|
||||
- uses: goto-bus-stop/setup-zig@v1
|
||||
- uses: goto-bus-stop/setup-zig@v2
|
||||
with:
|
||||
version: 0.7.0 # The default is 0.5.0
|
||||
version: 0.7.0
|
||||
```
|
||||
|
||||
To use the nightly builds, set:
|
||||
```yaml
|
||||
- uses: goto-bus-stop/setup-zig@v1
|
||||
with:
|
||||
version: master
|
||||
```
|
||||
The default is to use the nightly `master` builds.
|
||||
|
||||
Or [pin to a specific commit](https://github.com/goto-bus-stop/setup-zig/issues/13) using `version+commithash` syntax:
|
||||
```yaml
|
||||
- uses: goto-bus-stop/setup-zig@v1
|
||||
- uses: goto-bus-stop/setup-zig@v2
|
||||
with:
|
||||
version: 0.6.0+4b48fccad
|
||||
```
|
||||
@@ -53,18 +48,6 @@ If you are running Zig on Windows machines, you need to make sure that your .zig
|
||||
*.zig text eol=lf
|
||||
```
|
||||
|
||||
This action caches the downloaded compilers in your repository's Actions cache by default,
|
||||
to reduce the load on the Zig Foundation's servers. Cached compilers are only about 60MB
|
||||
each per version/OS/architecture.
|
||||
|
||||
If this is really bad for you for some reason you can disable the caching.
|
||||
|
||||
```yaml
|
||||
- uses: goto-bus-stop/setup-zig@v1
|
||||
with:
|
||||
cache: false
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[Apache-2.0](LICENSE.md)
|
||||
|
||||
@@ -8,11 +8,7 @@ inputs:
|
||||
version:
|
||||
description: 'Version of the zig compiler to use (must be 0.3.0 or up)'
|
||||
required: true
|
||||
default: '0.5.0'
|
||||
cache:
|
||||
description: 'Cache downloaded compilers for faster action runs. Strongly recommended.'
|
||||
required: false
|
||||
default: 'true'
|
||||
default: 'master'
|
||||
runs:
|
||||
using: 'node12'
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
|
||||
59671
dist/index.js
vendored
59671
dist/index.js
vendored
File diff suppressed because one or more lines are too long
41
index.js
41
index.js
@@ -4,8 +4,7 @@ const os = require('os')
|
||||
const path = require('path')
|
||||
const semver = require('semver')
|
||||
const actions = require('@actions/core')
|
||||
const cache = require('@actions/cache')
|
||||
const toolCache = require('@actions/tool-cache')
|
||||
const cache = require('@actions/tool-cache')
|
||||
const {
|
||||
extForPlatform,
|
||||
resolveCommit,
|
||||
@@ -14,60 +13,40 @@ const {
|
||||
|
||||
const TOOL_NAME = 'zig'
|
||||
|
||||
async function downloadZig (platform, version, useCache = true) {
|
||||
async function downloadZig (platform, version) {
|
||||
const ext = extForPlatform(platform)
|
||||
|
||||
const { downloadUrl, variantName, version: useVersion } = version.includes('+')
|
||||
? resolveCommit(platform, version)
|
||||
: await resolveVersion(platform, version)
|
||||
|
||||
const cachedPath = toolCache.find(TOOL_NAME, useVersion)
|
||||
const cachedPath = cache.find(TOOL_NAME, useVersion)
|
||||
if (cachedPath) {
|
||||
actions.info(`using cached zig install: ${cachedPath}`)
|
||||
return cachedPath
|
||||
}
|
||||
|
||||
const cacheKey = `${TOOL_NAME}-${variantName}`
|
||||
if (useCache) {
|
||||
const restorePath = path.join(process.env.RUNNER_TOOL_CACHE, TOOL_NAME, useVersion, os.arch())
|
||||
actions.info(`attempting restore of ${cacheKey} to ${restorePath}`)
|
||||
const restoredKey = await cache.restoreCache([restorePath], cacheKey)
|
||||
if (restoredKey) {
|
||||
actions.info(`using cached zig install: ${restorePath}`)
|
||||
return restorePath
|
||||
}
|
||||
}
|
||||
|
||||
actions.info(`no cached version found. downloading zig ${variantName}`)
|
||||
const downloadPath = await toolCache.downloadTool(downloadUrl)
|
||||
const downloadPath = await cache.downloadTool(downloadUrl)
|
||||
const zigPath = ext === 'zip'
|
||||
? await toolCache.extractZip(downloadPath)
|
||||
: await toolCache.extractTar(downloadPath, undefined, 'x')
|
||||
? await cache.extractZip(downloadPath)
|
||||
: await cache.extractTar(downloadPath, undefined, 'x')
|
||||
|
||||
const binPath = path.join(zigPath, variantName)
|
||||
const cachePath = await toolCache.cacheDir(binPath, TOOL_NAME, useVersion)
|
||||
|
||||
if (useCache) {
|
||||
actions.info(`adding zig ${useVersion} at ${cachePath} to local cache ${cacheKey}`)
|
||||
await cache.saveCache([cachePath], cacheKey)
|
||||
}
|
||||
const cachePath = await cache.cacheDir(binPath, TOOL_NAME, useVersion)
|
||||
actions.info(`added zig ${useVersion} to the tool cache`)
|
||||
|
||||
return cachePath
|
||||
}
|
||||
|
||||
async function main () {
|
||||
const version = actions.getInput('version') || '0.5.0'
|
||||
const useCache = actions.getInput('cache') || 'true'
|
||||
const version = actions.getInput('version') || 'master'
|
||||
if (semver.valid(version) && semver.lt(version, '0.3.0')) {
|
||||
actions.setFailed('This action does not work with Zig 0.1.0 and Zig 0.2.0')
|
||||
return
|
||||
}
|
||||
if (useCache !== 'false' && useCache !== 'true') {
|
||||
actions.setFailed('`with.cache` must be "true" or "false"')
|
||||
return
|
||||
}
|
||||
|
||||
const zigPath = await downloadZig(os.platform(), version, Boolean(useCache))
|
||||
const zigPath = await downloadZig(os.platform(), version)
|
||||
|
||||
// Add the `zig` binary to the $PATH
|
||||
actions.addPath(zigPath)
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
{
|
||||
"name": "setup-zig",
|
||||
"description": "Use the zig compiler in your Github Action",
|
||||
"version": "1.4.0",
|
||||
"version": "2.0.2",
|
||||
"author": "Renée Kooi <renee@kooi.me>",
|
||||
"bugs": {
|
||||
"url": "https://github.com/goto-bus-stop/setup-zig/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/cache": "^3.2.1",
|
||||
"@actions/core": "^1.2.2",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"semver": "^7.1.3",
|
||||
"simple-get": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.18.8",
|
||||
"esbuild": "^0.17.19",
|
||||
"standard": "^17.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/goto-bus-stop/setup-zig",
|
||||
@@ -31,7 +30,7 @@
|
||||
"url": "https://github.com/goto-bus-stop/setup-zig.git"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "esbuild index.js --outdir=dist --keep-names --bundle --platform=node --target=node12",
|
||||
"prepare": "esbuild index.js --outdir=dist --bundle --platform=node",
|
||||
"test": "standard && node test"
|
||||
},
|
||||
"standard": {
|
||||
|
||||
Reference in New Issue
Block a user