diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 0000000..973354a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,37 @@ +--- +name: Bug Report +description: File a bug report +labels: ["needs: investigation", "type: bug"] +body: + - type: markdown + attributes: + value: | + Consider [sponsoring Dokku](https://github.com/sponsors/dokku). Sponsorship goes directly to supporting activities such as fixing bugs and general maintenance. + - type: textarea + id: description + attributes: + label: Description of problem + description: What happened? What did you expect to happen? + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps to reproduce + description: What are the steps that we need to follow to reproduce this issue? + validations: + required: true + - type: textarea + id: report-output + attributes: + label: procfile-util --version + description: Please paste the output of the command `procfile-util --version` + validations: + required: true + - type: textarea + id: logs + attributes: + label: "Output of failing command" + render: shell + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml new file mode 100644 index 0000000..7e3ee6d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -0,0 +1,18 @@ +--- +name: Feature Request +description: Have an idea for a new feature? Ask away! +labels: ["needs: plan", "type: enhancement"] +body: + - type: markdown + attributes: + value: | + While pull requests are always welcome, feel free to fill this out with an idea of what you would like to happen and we can discuss if and how it should be implemented in `procfile-util`. + + Consider [sponsoring Dokku](https://github.com/sponsors/dokku). Sponsorship goes directly to supporting activities such as implementing new features and upgrading existing functionality. + - type: textarea + id: description + attributes: + label: Description of feature + description: When you perform what command or action, what do you think should happen? + validations: + required: true diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a0a2867..99b6fb4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,3 +9,7 @@ updates: directory: "/" schedule: interval: "daily" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml new file mode 100644 index 0000000..7453638 --- /dev/null +++ b/.github/linters/.markdown-lint.yml @@ -0,0 +1,6 @@ +--- +default: true + +# Line length +# https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md013 +MD013: false diff --git a/.github/linters/.yamllint.yml b/.github/linters/.yamllint.yml new file mode 100644 index 0000000..75da2b7 --- /dev/null +++ b/.github/linters/.yamllint.yml @@ -0,0 +1,5 @@ +--- +extends: default + +rules: + line-length: disable diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2873345..a989748 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,7 @@ --- name: CI +# yamllint disable-line rule:truthy on: pull_request: branches: @@ -21,24 +22,24 @@ jobs: PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }} steps: - - uses: actions/checkout@v2 - - name: make version - run: | - make version .env.docker - - run: make ci-report - - run: make build-docker-image - - run: make build-in-docker - - run: make validate-in-docker - - name: upload packages - uses: actions/upload-artifact@v2 - with: - name: build - path: build/**/* - - name: make release-in-docker - run: | - if [[ "${GITHUB_REF#refs/heads/}" == "release" ]]; then - export CI_BRANCH=${GITHUB_REF#refs/heads/} - export PACKAGECLOUD_REPOSITORY=dokku/dokku - rm .env.docker - make .env.docker release-in-docker release-packagecloud-in-docker - fi + - uses: actions/checkout@v3 + - name: make version + run: | + make version .env.docker + - run: make ci-report + - run: make build-docker-image + - run: make build-in-docker + - run: make validate-in-docker + - name: upload packages + uses: actions/upload-artifact@v3 + with: + name: build + path: build/**/* + - name: make release-in-docker + run: | + if [[ "${GITHUB_REF#refs/heads/}" == "release" ]]; then + export CI_BRANCH=${GITHUB_REF#refs/heads/} + export PACKAGECLOUD_REPOSITORY=dokku/dokku + rm .env.docker + make .env.docker release-in-docker release-packagecloud-in-docker + fi diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..49b45a3 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,40 @@ +--- +name: "CodeQL" + +# yamllint disable-line rule:truthy +on: + push: + branches: [master] + pull_request: + branches: [master] + schedule: + - cron: '31 22 * * 5' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: ['go'] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..04d8686 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,74 @@ +--- +name: 'lint' + +# yamllint disable-line rule:truthy +on: + pull_request: + branches: + - '*' + push: + branches: + - 'master' + +jobs: + hadolint: + name: hadolint + runs-on: ubuntu-20.04 + steps: + - name: Clone + uses: actions/checkout@v3 + - name: Run hadolint + uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf + # v1.5.0 => c27bd9edc1e95eed30474db8f295ff5807ebca14 + + markdown-lint: + name: markdown-lint + runs-on: ubuntu-20.04 + steps: + - name: Clone + uses: actions/checkout@v3 + - name: Run markdown-lint + uses: avto-dev/markdown-lint@04d43ee9191307b50935a753da3b775ab695eceb + # v1.5.0 => 04d43ee9191307b50935a753da3b775ab695eceb + with: + config: '.github/linters/.markdown-lint.yml' + args: './README.md' + + shellcheck: + name: shellcheck + runs-on: ubuntu-20.04 + steps: + - name: Clone + uses: actions/checkout@v3 + - name: Run shellcheck + uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 + # 1.1.0 => 94e0aab03ca135d11a35e5bfc14e6746dc56e7e9 + env: + SHELLCHECK_OPTS: -s bash + shfmt: + name: shfmt + runs-on: ubuntu-20.04 + steps: + - name: Clone + uses: actions/checkout@v3 + - name: Run shfmt + uses: luizm/action-sh-checker@76ab0b22e1f194e4a582edc7969df6485c4e9246 + # v0.3.0 => 7f44869033b40ee4ffe7dc76c87a1bc66e3d025a + env: + GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} + SHFMT_OPTS: -l -d -i 2 + with: + sh_checker_shellcheck_disable: true + sh_checker_comment: true + + yamllint: + name: yamllint + runs-on: ubuntu-20.04 + steps: + - name: Clone + uses: actions/checkout@v3 + - name: Run yamllint + uses: ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c + # v3.0.2 => c19bd0523a9011c3a3960fe6640a0882b59af15d + with: + config_file: '.github/linters/.yamllint.yml' diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0e971fc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM golang:1.20.7-bullseye + +# hadolint ignore=DL3027 +RUN apt-get update \ + && apt install apt-transport-https build-essential curl gnupg2 jq lintian rsync rubygems-integration ruby-dev ruby -qy \ + && git clone https://github.com/bats-core/bats-core.git /tmp/bats-core \ + && /tmp/bats-core/install.sh /usr/local \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# hadolint ignore=DL3028 +RUN gem install --quiet rake fpm package_cloud + +WORKDIR /src diff --git a/Dockerfile.build b/Dockerfile.build deleted file mode 100644 index ebab3ff..0000000 --- a/Dockerfile.build +++ /dev/null @@ -1,12 +0,0 @@ -FROM golang:1.18.1-buster - -# hadolint ignore=DL3027 -RUN apt-get update \ - && apt install apt-transport-https bats build-essential curl gnupg2 jq lintian rpm rsync rubygems-integration ruby-dev ruby -qy \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -# hadolint ignore=DL3028 -RUN gem install --no-ri --no-rdoc --quiet rake fpm package_cloud - -WORKDIR /src diff --git a/Makefile b/Makefile index 811aec1..8daa292 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ MAINTAINER_NAME = Jose Diaz-Gonzalez REPOSITORY = procfile-util HARDWARE = $(shell uname -m) SYSTEM_NAME = $(shell uname -s | tr '[:upper:]' '[:lower:]') -BASE_VERSION ?= 0.15.0 +BASE_VERSION ?= 0.16.0 IMAGE_NAME ?= $(MAINTAINER)/$(REPOSITORY) PACKAGECLOUD_REPOSITORY ?= dokku/dokku-betafish @@ -43,17 +43,17 @@ targets = $(addsuffix -in-docker, $(LIST)) @echo "VERSION=$(VERSION)" >> .env.docker build: prebuild - @$(MAKE) build/darwin/$(NAME) + @$(MAKE) build/darwin/$(NAME)-amd64 + @$(MAKE) build/darwin/$(NAME)-arm64 @$(MAKE) build/linux/$(NAME)-amd64 @$(MAKE) build/linux/$(NAME)-arm64 @$(MAKE) build/linux/$(NAME)-armhf @$(MAKE) build/deb/$(NAME)_$(VERSION)_amd64.deb @$(MAKE) build/deb/$(NAME)_$(VERSION)_arm64.deb @$(MAKE) build/deb/$(NAME)_$(VERSION)_armhf.deb - @$(MAKE) build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm build-docker-image: - docker build --rm -q -f Dockerfile.build -t $(IMAGE_NAME):build . + docker build --rm -q -f Dockerfile -t $(IMAGE_NAME):build . $(targets): %-in-docker: .env.docker docker run \ @@ -65,15 +65,21 @@ $(targets): %-in-docker: .env.docker --workdir /src/github.com/$(MAINTAINER)/$(REPOSITORY) \ $(IMAGE_NAME):build make -e $(@:-in-docker=) -build/darwin/$(NAME): +build/darwin/$(NAME)-amd64: mkdir -p build/darwin - CGO_ENABLED=0 GOOS=darwin go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \ + CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \ -ldflags "-s -w -X main.Version=$(VERSION)" \ - -o build/darwin/$(NAME) + -o build/darwin/$(NAME)-amd64 + +build/darwin/$(NAME)-arm64: + mkdir -p build/darwin + CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \ + -ldflags "-s -w -X main.Version=$(VERSION)" \ + -o build/darwin/$(NAME)-arm64 build/linux/$(NAME)-amd64: mkdir -p build/linux - CGO_ENABLED=0 GOOS=linux go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \ + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \ -ldflags "-s -w -X main.Version=$(VERSION)" \ -o build/linux/$(NAME)-amd64 @@ -149,27 +155,6 @@ build/deb/$(NAME)_$(VERSION)_armhf.deb: build/linux/$(NAME)-armhf build/linux/$(NAME)-armhf=/usr/bin/$(NAME) \ LICENSE=/usr/share/doc/$(NAME)/copyright -build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm: build/linux/$(NAME)-amd64 - export SOURCE_DATE_EPOCH=$(shell git log -1 --format=%ct) \ - && mkdir -p build/rpm \ - && fpm \ - --architecture x86_64 \ - --category utils \ - --description "$$PACKAGE_DESCRIPTION" \ - --input-type dir \ - --license 'MIT License' \ - --maintainer "$(MAINTAINER_NAME) <$(EMAIL)>" \ - --name $(NAME) \ - --output-type rpm \ - --package build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm \ - --rpm-os linux \ - --url "https://github.com/$(MAINTAINER)/$(REPOSITORY)" \ - --vendor "" \ - --version $(VERSION) \ - --verbose \ - build/linux/$(NAME)-amd64=/usr/bin/$(NAME) \ - LICENSE=/usr/share/doc/$(NAME)/copyright - clean: rm -rf build release validation @@ -196,35 +181,33 @@ release: build bin/gh-release bin/gh-release-body tar -zcf release/$(NAME)_$(VERSION)_linux_amd64.tgz -C build/linux $(NAME)-amd64 tar -zcf release/$(NAME)_$(VERSION)_linux_arm64.tgz -C build/linux $(NAME)-arm64 tar -zcf release/$(NAME)_$(VERSION)_linux_armhf.tgz -C build/linux $(NAME)-armhf - tar -zcf release/$(NAME)_$(VERSION)_darwin_$(HARDWARE).tgz -C build/darwin $(NAME) + tar -zcf release/$(NAME)_$(VERSION)_darwin_amd64.tgz -C build/darwin $(NAME)-amd64 + tar -zcf release/$(NAME)_$(VERSION)_darwin_arm64.tgz -C build/darwin $(NAME)-arm64 cp build/deb/$(NAME)_$(VERSION)_amd64.deb release/$(NAME)_$(VERSION)_amd64.deb cp build/deb/$(NAME)_$(VERSION)_arm64.deb release/$(NAME)_$(VERSION)_arm64.deb cp build/deb/$(NAME)_$(VERSION)_armhf.deb release/$(NAME)_$(VERSION)_armhf.deb - cp build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm release/$(NAME)-$(VERSION)-1.x86_64.rpm bin/gh-release create $(MAINTAINER)/$(REPOSITORY) $(VERSION) $(shell git rev-parse --abbrev-ref HEAD) bin/gh-release-body $(MAINTAINER)/$(REPOSITORY) v$(VERSION) release-packagecloud: @$(MAKE) release-packagecloud-deb - @$(MAKE) release-packagecloud-rpm release-packagecloud-deb: build/deb/$(NAME)_$(VERSION)_amd64.deb build/deb/$(NAME)_$(VERSION)_arm64.deb build/deb/$(NAME)_$(VERSION)_armhf.deb package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/bionic build/deb/$(NAME)_$(VERSION)_amd64.deb package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/focal build/deb/$(NAME)_$(VERSION)_amd64.deb package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/jammy build/deb/$(NAME)_$(VERSION)_amd64.deb - package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/stretch build/deb/$(NAME)_$(VERSION)_amd64.deb package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/buster build/deb/$(NAME)_$(VERSION)_amd64.deb package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bullseye build/deb/$(NAME)_$(VERSION)_amd64.deb + package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bookworm build/deb/$(NAME)_$(VERSION)_amd64.deb package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/focal build/deb/$(NAME)_$(VERSION)_arm64.deb package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/jammy build/deb/$(NAME)_$(VERSION)_arm64.deb + package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bullseye build/deb/$(NAME)_$(VERSION)_arm64.deb + package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bookworm build/deb/$(NAME)_$(VERSION)_arm64.deb package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/focal build/deb/$(NAME)_$(VERSION)_armhf.deb package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/jammy build/deb/$(NAME)_$(VERSION)_armhf.deb package_cloud push $(PACKAGECLOUD_REPOSITORY)/raspbian/buster build/deb/$(NAME)_$(VERSION)_armhf.deb package_cloud push $(PACKAGECLOUD_REPOSITORY)/raspbian/bullseye build/deb/$(NAME)_$(VERSION)_armhf.deb -release-packagecloud-rpm: build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm - package_cloud push $(PACKAGECLOUD_REPOSITORY)/el/7 build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm - validate: mkdir -p validation lintian build/deb/$(NAME)_$(VERSION)_amd64.deb || true @@ -239,14 +222,14 @@ validate: cd validation && ar -x ../build/deb/$(NAME)_$(VERSION)_amd64.deb cd validation && ar -x ../build/deb/$(NAME)_$(VERSION)_arm64.deb cd validation && ar -x ../build/deb/$(NAME)_$(VERSION)_armhf.deb - cd validation && rpm2cpio ../build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm > $(NAME)-$(VERSION)-1.x86_64.cpio - ls -lah build/deb build/rpm validation + ls -lah build/deb validation sha1sum build/deb/$(NAME)_$(VERSION)_amd64.deb sha1sum build/deb/$(NAME)_$(VERSION)_arm64.deb sha1sum build/deb/$(NAME)_$(VERSION)_armhf.deb - sha1sum build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm bats test.bats prebuild: + git config --global --add safe.directory $(shell pwd) + git status go install github.com/go-bindata/go-bindata/...@latest cd export && go-bindata -pkg export templates/... diff --git a/go.mod b/go.mod index 8981670..386a1ee 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,11 @@ module procfile-util -go 1.18 +go 1.19 require ( - github.com/akamensky/argparse v1.3.1 + github.com/akamensky/argparse v1.4.0 github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2 - github.com/joho/godotenv v1.4.0 + github.com/joho/godotenv v1.5.1 gopkg.in/alessio/shellescape.v1 v1.0.0-20170105083845-52074bc9df61 ) diff --git a/go.sum b/go.sum index 6c033c8..757316a 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,10 @@ -github.com/akamensky/argparse v1.3.1 h1:kP6+OyvR0fuBH6UhbE6yh/nskrDEIQgEA1SUXDPjx4g= -github.com/akamensky/argparse v1.3.1/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA= +github.com/akamensky/argparse v1.4.0 h1:YGzvsTqCvbEZhL8zZu2AiA5nq805NZh75JNj4ajn1xc= +github.com/akamensky/argparse v1.4.0/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA= github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0= github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2 h1:axBiC50cNZOs7ygH5BgQp4N+aYrZ2DNpWZ1KG3VOSOM= github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2/go.mod h1:jnzFpU88PccN/tPPhCpnNU8mZphvKxYM9lLNkd8e+os= -github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg= -github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= gopkg.in/alessio/shellescape.v1 v1.0.0-20170105083845-52074bc9df61 h1:8ajkpB4hXVftY5ko905id+dOnmorcS2CHNxxHLLDcFM= gopkg.in/alessio/shellescape.v1 v1.0.0-20170105083845-52074bc9df61/go.mod h1:IfMagxm39Ys4ybJrDb7W3Ob8RwxftP0Yy+or/NVz1O8=