3
3
4
4
name : Build Semgrep Wheel Artifact
5
5
6
- on : workflow_dispatch
6
+ on : [push, workflow_dispatch]
7
7
8
8
permissions :
9
9
contents : read
@@ -12,44 +12,44 @@ jobs:
12
12
build-semgrep-wheel :
13
13
name : Build Semgrep wheel
14
14
runs-on : ubuntu-latest
15
+ permissions :
16
+ packages : write # to push the docker image
15
17
defaults :
16
18
run :
17
19
shell : bash
18
20
19
21
steps :
20
- - name : Install git # for cloning Semgrep repository
21
- run : |
22
- sudo apt-get install git
23
-
24
- - name : Clone Semgrep v1.113.0 repository
25
- run : |
26
- git init
27
- git remote add origin https://github.com/semgrep/semgrep.git
28
- git fetch --depth 1 origin 4729a05d24bf9cee8face447e8a6d418037d61d8
29
- git checkout FETCH_HEAD
30
- git submodule update --init --recursive --depth 1
22
+ # To update the semgrep version, please apply the following changes:
23
+ # - change the version tag in the 'name' description
24
+ # - change the 'ref' field to use the commit hash of that tag
25
+ - name : Check out Semgrep v1.113.0 repository
26
+ uses : actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
27
+ with :
28
+ repository : semgrep/semgrep.git
29
+ ref : 4729a05d24bf9cee8face447e8a6d418037d61d8 # v1.113.0
30
+ fetch-depth : 1 # only need most recent commits to this tag
31
+ submodules : recursive # semgrep uses many of their own ocaml submodules, which are required to build
31
32
32
33
- name : Build wheel through docker
34
+ # we build to the 'semgrep-wheel' target as we don't need the performance testing, and want to extract the wheel
33
35
run : |
34
36
docker build --target semgrep-wheel -t semgrep .
35
37
docker create --name temp semgrep
36
- mkdir -p dist /
37
- docker cp temp:/semgrep/cli/dist/ dist /
38
+ mkdir -p wheels /
39
+ docker cp temp:/semgrep/cli/dist/. wheels /
38
40
docker container rm temp
39
41
40
- - name : Get wheel name
42
+ # - name: Log in to GitHub Container Registry
43
+ # run: docker login ghcr.io --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }}
44
+
45
+ # The manylinux image will be a static binary built using musl, suitable for Oracle linux
46
+ - name : Build and push semgrep wheel image
41
47
run : |
42
- WHEELS=($(find ./dist -type f -name "*manylinux*.whl"))
43
- if [ "${WHEELS[@]}" -ne 1]; then
44
- echo "Expected a single wheel file built by semgrep dockerfile"
45
- exit 1
46
- fi
47
- echo "WHEEL_PATH=${WHEELS[0]}" >> "$GITHUB_ENV"
48
-
49
- - uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
50
- with :
51
- name : semgrep_wheel_manylinux.whl
52
- path : ${{ env.WHEEL_PATH }}
53
- if-no-files-found : error
54
- compression-level : 0 # don't compress the wheel file
55
- retention-days : 90 # uploaded wheel valid for 90 days, before workflow must be run again
48
+ cd wheels
49
+ WHEEL=$(find . -type f -name 'semgrep-*manylinux*.whl')
50
+ echo "FROM scratch
51
+ COPY ${WHEEL} /semgrep_wheel.whl" >> Dockerfile.semgrep
52
+ docker build -t ghcr.io/macaron/macaron-deps:latest -f Dockerfile.semgrep .
53
+
54
+
55
+ # docker push ghcr.io/macaron/macaron-deps:latest
0 commit comments