Skip to content

Commit 6a4a2d2

Browse files
authored
fix: use fork of git-crypt to support ubuntu-24.04 runners (#167)
* fix: use fork Signed-off-by: Markus Maga <[email protected]> * fix: use newer version Signed-off-by: Markus Maga <[email protected]> * fix: update dist Signed-off-by: Markus Maga <[email protected]> * fix: wrong version tag Signed-off-by: Markus Maga <[email protected]> * fix: update dist?? Signed-off-by: Markus Maga <[email protected]> * fix(husky): pre-commit hook that fixes dist Signed-off-by: Markus Maga <[email protected]> * fix: attempt Signed-off-by: Markus Maga <[email protected]> * fix Signed-off-by: Markus Maga <[email protected]> * fix Signed-off-by: Markus Maga <[email protected]> * fix Signed-off-by: Markus Maga <[email protected]> * fix: try chmod Signed-off-by: Markus Maga <[email protected]> * fix: fail on ubuntu20 Signed-off-by: Markus Maga <[email protected]> * fix: one error message Signed-off-by: Markus Maga <[email protected]> * fix: stop testing ubuntu 20 Signed-off-by: Markus Maga <[email protected]> * fix: update readme Signed-off-by: Markus Maga <[email protected]> * fix: update readme Signed-off-by: Markus Maga <[email protected]> --------- Signed-off-by: Markus Maga <[email protected]>
1 parent 1a22213 commit 6a4a2d2

File tree

9 files changed

+62
-55
lines changed

9 files changed

+62
-55
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
os: [ubuntu-latest, ubuntu-20.04, ubuntu-22.04, ubuntu-24.04]
27+
os: [ubuntu-latest, ubuntu-22.04, ubuntu-24.04]
2828
runs-on: ${{ matrix.os }}
2929
steps:
3030
- uses: actions/checkout@v4

.husky/pre-commit

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
3-
4-
npm run package
1+
npm run all
52
git add dist/

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
This is a GitHub Action for setting up git-crypt in a GitHub Actions workflow. Git-crypt is a tool for encrypting and decrypting files in a Git repository.
44
The action will download the source for the git-crypt CLI and build it in runtime, it may also be cached in the tools cache.
55

6+
**v4**:
7+
8+
- works on ubuntu 22+
9+
- uses a fork of git-crypt https://github.com/maxisam/git-crypt/
10+
11+
**v3**:
12+
13+
- works on ubuntu 20 and 22
14+
- uses https://github.com/AGWA/git-crypt
15+
616
## Pre-requisite for self-hosted runners
717

818
This action requires openssl and openssl-devel to be installed on your runner (exists by default on github hosted runners).
@@ -23,7 +33,7 @@ jobs:
2333
runs-on: ubuntu-latest
2434
steps:
2535
- uses: actions/checkout@v4
26-
- uses: Flydiverny/setup-git-crypt@v3
36+
- uses: flydiverny/setup-git-crypt@v4
2737
```
2838
2939
In this example, the `setup-git-crypt` action is added as a step in the `build` job, and it will be run when the workflow is triggered. The `setup-git-crypt` action will install and configure git-crypt in the environment where the action is running, allowing you to use git-crypt in the rest of your workflow.

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ inputs:
88
version:
99
required: false
1010
description: 'git-crypt version'
11-
default: '0.7.0'
11+
default: '0.8.1'
1212
runs:
1313
using: 'node20'
1414
main: 'dist/index.js'

dist/index.js

Lines changed: 20 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "setup-git-crypt",
3-
"version": "0.1.0",
3+
"version": "4.0.0",
44
"private": true,
55
"description": "TypeScript template action",
66
"main": "lib/main.js",
@@ -10,7 +10,8 @@
1010
"format-check": "prettier --check '**/*.ts'",
1111
"lint": "eslint src/**/*.ts",
1212
"package": "ncc build --source-map --license licenses.txt",
13-
"all": "npm run build && npm run format && npm run lint && npm run package && echo"
13+
"all": "npm run build && npm run format && npm run lint && npm run package && echo",
14+
"prepare": "husky"
1415
},
1516
"repository": {
1617
"type": "git",
@@ -35,7 +36,7 @@
3536
"@vercel/ncc": "^0.38.1",
3637
"eslint": "^8.56.0",
3738
"eslint-plugin-github": "^4.10.1",
38-
"husky": "^9.0.10",
39+
"husky": "^9.1.7",
3940
"js-yaml": "^4.1.0",
4041
"prettier": "^3.2.4",
4142
"typescript": "^5.3.3"

src/main.ts

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import * as core from '@actions/core'
2-
import * as exec from '@actions/exec'
2+
// import * as exec from '@actions/exec'
33
import * as tc from '@actions/tool-cache'
44
import * as os from 'os'
55
import * as path from 'path'
6+
import {chmod, copyFile, mkdir} from 'fs/promises'
67

78
async function run(): Promise<void> {
9+
if (process.env.ImageOS === 'ubuntu20') {
10+
core.setFailed(
11+
'Please use previous version of setup-git-crypt, this version requires ubuntu22 or higher'
12+
)
13+
process.exit(1)
14+
}
15+
816
const version = core.getInput('version')
917

1018
try {
@@ -14,35 +22,19 @@ async function run(): Promise<void> {
1422
if (toolPath) {
1523
core.info(`Found in cache @ ${toolPath}`)
1624
} else {
17-
const destination = path.join(os.homedir(), '.git-crypt')
25+
const destination = path.join(os.homedir(), '.git-crypt/')
1826
core.info(`Install destination is ${destination}`)
1927

2028
const downloaded = await tc.downloadTool(
21-
`https://www.agwa.name/projects/git-crypt/downloads/git-crypt-${version}.tar.gz`
22-
)
23-
const extractedPath = await tc.extractTar(downloaded, destination)
24-
const workspace = path.join(extractedPath, `git-crypt-${version}`)
25-
core.info(`Extracted ${downloaded} to ${extractedPath}`)
26-
27-
let extraArgs: string[] = []
28-
29-
if (process.env.ImageOS === 'ubuntu22') {
30-
extraArgs = [`CXXFLAGS='-DOPENSSL_API_COMPAT=0x30000000L'`]
31-
}
32-
33-
await exec.getExecOutput(
34-
'make',
35-
['install', `PREFIX=${extractedPath}`, ...extraArgs],
36-
{
37-
cwd: workspace
38-
}
29+
`https://github.com/maxisam/git-crypt/releases/download/${version}/git-crypt-${version}-linux-x86_64`
3930
)
4031

41-
toolPath = await tc.cacheDir(
42-
path.join(destination, 'bin'),
43-
'git-crypt',
44-
version
45-
)
32+
await mkdir(destination, {recursive: true})
33+
await chmod(downloaded, 0o755)
34+
35+
await copyFile(downloaded, path.join(destination, 'git-crypt'))
36+
37+
toolPath = await tc.cacheDir(destination, 'git-crypt', version)
4638
}
4739

4840
core.addPath(toolPath)

0 commit comments

Comments
 (0)