diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..df9ae63 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +custom: ['https://www.paypal.me/appleboy46'] diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..632e8eb --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + - package-ecosystem: gomod + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..2d9bcdd --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,54 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '41 23 * * 6' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://git.io/codeql-language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..e4b6d7d --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,71 @@ +name: Docker Image + +on: + push: + branches: + - master + tags: + - "v*" + pull_request: + branches: + - "master" + +jobs: + build-docker: + runs-on: ubuntu-latest + steps: + - name: Setup go + uses: actions/setup-go@v4 + with: + go-version: "^1" + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Build binary + run: | + make build_linux_amd64 + make build_linux_arm + make build_linux_arm64 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker meta + id: docker-meta + uses: docker/metadata-action@v4 + with: + images: | + ${{ github.repository }} + ghcr.io/${{ github.repository }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm,linux/arm64 + file: docker/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.docker-meta.outputs.tags }} + labels: ${{ steps.docker-meta.outputs.labels }} diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml new file mode 100644 index 0000000..565c382 --- /dev/null +++ b/.github/workflows/goreleaser.yml @@ -0,0 +1,35 @@ +name: Goreleaser + +on: + push: + tags: + - '*' + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - + name: Setup go + uses: actions/setup-go@v4 + with: + go-version: '^1' + + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + with: + # either 'goreleaser' (default) or 'goreleaser-pro' + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..6a8e47d --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,40 @@ +name: Lint and Testing + +on: + push: + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Setup go + uses: actions/setup-go@v4 + with: + go-version: "^1" + - name: Checkout repository + uses: actions/checkout@v3 + - name: Setup golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest + args: --verbose + + - uses: hadolint/hadolint-action@v3.1.0 + name: hadolint for Dockerfile + with: + dockerfile: docker/Dockerfile + + testing: + runs-on: ubuntu-latest + container: golang:1.19-alpine + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: testing + run: | + make test + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..17db224 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,20 @@ +FROM alpine:3.17 + +ARG TARGETOS +ARG TARGETARCH + +LABEL maintainer="Bo-Yi Wu " \ + org.label-schema.name="SSH Plugin" \ + org.label-schema.vendor="Bo-Yi Wu" \ + org.label-schema.schema-version="1.0" + +LABEL org.opencontainers.image.source=https://github.com/appleboy/drone-telegram +LABEL org.opencontainers.image.description="plugin for sending telegram notifications" +LABEL org.opencontainers.image.licenses=MIT + +RUN apk add --no-cache ca-certificates=20230506-r0 && \ + rm -rf /var/cache/apk/* + +COPY release/${TARGETOS}/${TARGETARCH}/drone-telegram /bin/ + +ENTRYPOINT ["/bin/drone-telegram"] diff --git a/docker/Dockerfile.linux.amd64 b/docker/Dockerfile.linux.amd64 deleted file mode 100644 index d8650dc..0000000 --- a/docker/Dockerfile.linux.amd64 +++ /dev/null @@ -1,10 +0,0 @@ -FROM plugins/base:linux-amd64 - -LABEL maintainer="Bo-Yi Wu " \ - org.label-schema.name="Drone telegram" \ - org.label-schema.vendor="Bo-Yi Wu" \ - org.label-schema.schema-version="1.0" - -COPY release/linux/amd64/drone-telegram /bin/ - -ENTRYPOINT ["/bin/drone-telegram"] diff --git a/docker/Dockerfile.linux.arm b/docker/Dockerfile.linux.arm deleted file mode 100644 index 00f48e2..0000000 --- a/docker/Dockerfile.linux.arm +++ /dev/null @@ -1,10 +0,0 @@ -FROM plugins/base:linux-arm - -LABEL maintainer="Bo-Yi Wu " \ - org.label-schema.name="Drone telegram" \ - org.label-schema.vendor="Bo-Yi Wu" \ - org.label-schema.schema-version="1.0" - -COPY release/linux/arm/drone-telegram /bin/ - -ENTRYPOINT ["/bin/drone-telegram"] diff --git a/docker/Dockerfile.linux.arm64 b/docker/Dockerfile.linux.arm64 deleted file mode 100644 index db4c644..0000000 --- a/docker/Dockerfile.linux.arm64 +++ /dev/null @@ -1,10 +0,0 @@ -FROM plugins/base:linux-arm64 - -LABEL maintainer="Bo-Yi Wu " \ - org.label-schema.name="Drone telegram" \ - org.label-schema.vendor="Bo-Yi Wu" \ - org.label-schema.schema-version="1.0" - -COPY release/linux/arm64/drone-telegram /bin/ - -ENTRYPOINT ["/bin/drone-telegram"] diff --git a/docker/Dockerfile.windows.amd64 b/docker/Dockerfile.windows.amd64 deleted file mode 100644 index d2a63fa..0000000 --- a/docker/Dockerfile.windows.amd64 +++ /dev/null @@ -1,10 +0,0 @@ -FROM microsoft/nanoserver:10.0.14393.1884 - -LABEL maintainer="Bo-Yi Wu " \ - org.label-schema.name="Drone telegram" \ - org.label-schema.vendor="Bo-Yi Wu" \ - org.label-schema.schema-version="1.0" - -COPY release/drone-telegram.exe /drone-telegram.exe - -ENTRYPOINT [ "\\drone-telegram.exe" ] diff --git a/docker/manifest.tmpl b/docker/manifest.tmpl deleted file mode 100644 index b5498cb..0000000 --- a/docker/manifest.tmpl +++ /dev/null @@ -1,25 +0,0 @@ -image: appleboy/drone-telegram:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} -{{#if build.tags}} -tags: -{{#each build.tags}} - - {{this}} -{{/each}} -{{/if}} -manifests: - - - image: appleboy/drone-telegram:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64 - platform: - architecture: amd64 - os: linux - - - image: appleboy/drone-telegram:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64 - platform: - architecture: arm64 - os: linux - variant: v8 - - - image: appleboy/drone-telegram:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm - platform: - architecture: arm - os: linux - variant: v7