Skip to content
This repository was archived by the owner on Nov 2, 2021. It is now read-only.

Commit b8d5fef

Browse files
author
Cosmin Cojocar
authored
Add go 1.15 version to the action (#30)
Signed-off-by: Cosmin Cojocar <ccojocar@cloudbees.com>
1 parent 98739d9 commit b8d5fef

File tree

4 files changed

+84
-2
lines changed

4 files changed

+84
-2
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.14
1+
FROM golang:1.15
22

33
LABEL name="Golang Action"
44
LABEL maintainer="Cedric Kring"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ steps:
6464
PROJECT_PATH: "./path/in/my/project"
6565
```
6666

67-
To use a specific golang version (1.10, 1.11, 1.12, 1.13, 1.14), defaults to the latest version:
67+
To use a specific golang version (1.10, 1.11, 1.12, 1.13, 1.14, 1.15), defaults to the latest version:
6868
```yaml
6969
steps:
7070
- name: Use Go 1.11

go1.15/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM golang:1.15
2+
3+
LABEL name="Golang Action"
4+
LABEL maintainer="Cedric Kring"
5+
LABEL version="1.5.2"
6+
LABEL repository="https://github.com/cedrickring/golang-action"
7+
8+
LABEL com.github.actions.name="Golang Action"
9+
LABEL com.github.actions.description="Run Golang commands"
10+
LABEL com.github.actions.icon="box"
11+
LABEL com.github.actions.color="blue"
12+
13+
# Install dep and check sha256 checksum matches for version 0.5.4 https://github.com/golang/dep/releases/tag/v0.5.4
14+
RUN set -eux; \
15+
curl -L -s https://github.com/golang/dep/releases/download/v0.5.4/dep-linux-amd64 -o "$GOPATH/bin/dep"; \
16+
echo "40a78c13753f482208d3f4bea51244ca60a914341050c588dad1f00b1acc116c $GOPATH/bin/dep" | sha256sum -c -; \
17+
chmod +x "${GOPATH}/bin/dep";
18+
19+
COPY entrypoint.sh /entrypoint.sh
20+
21+
ENTRYPOINT ["/entrypoint.sh"]
22+
CMD [""]

go1.15/entrypoint.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
if [ -z "${IMPORT}" ]; then
6+
IMPORT="${GITHUB_REPOSITORY}"
7+
fi
8+
WORKDIR="${GOPATH}/src/github.com/${IMPORT}"
9+
10+
# PROJECT_PATH specifies the subdirectory in the working directory that the Go project is
11+
if [ -z "${PROJECT_PATH}" ]; then
12+
PROJECT_PATH="."
13+
fi
14+
15+
# Go can only find dependencies if they're under $GOPATH/src.
16+
# GitHub Actions mounts your repository outside of $GOPATH.
17+
# So symlink the repository into $GOPATH, and then cd to it.
18+
mkdir -p "$(dirname "${WORKDIR}")"
19+
ln -s "${PWD}" "${WORKDIR}"
20+
cd "${WORKDIR}/${PROJECT_PATH}"
21+
22+
# If a command was specified with `args="..."`, then run it. Otherwise,
23+
# look for something useful to run.
24+
if [ $# -eq 0 ] || [ "$*" = "" ]; then
25+
if [ -r Makefile ]; then
26+
make
27+
else
28+
if [ -r go.mod ]; then
29+
export GO111MODULE=on
30+
# Check if using vendored dependencies
31+
if [ -d "vendor" ]; then
32+
export GOFLAGS="-mod=vendor"
33+
else
34+
# Ensure no go.mod changes are made that weren't committed
35+
export GOFLAGS="-mod=readonly"
36+
fi
37+
else
38+
if [ -r Gopkg.toml ]; then
39+
# Check if using vendored dependencies
40+
if [ -d "vendor" ]; then
41+
# Check that dep is in sync with /vendor dependencies and that running dep ensure doesn't result in modifications to Gopkg.lock/Gopkg.toml
42+
"$GOPATH/bin/dep" ensure && "$GOPATH/bin/dep" check
43+
git_workspace_status="$(git status --porcelain)"
44+
if [ -n "${git_workspace_status}" ]; then
45+
echo "Unexpected changes were found in dep /vendored. Please run $(dep ensure) and commit changes:";
46+
echo "${git_workspace_status}";
47+
exit 1;
48+
fi
49+
else
50+
# Run dep ensure to download and sync dependencies
51+
"$GOPATH/bin/dep" ensure
52+
fi
53+
fi
54+
fi
55+
go build ./...
56+
go test ./...
57+
fi
58+
else
59+
sh -c "$*"
60+
fi

0 commit comments

Comments
 (0)