mirror of
https://github.com/tfausak/github-release.git
synced 2025-07-23 04:13:02 +02:00
Update things for 2023 (#20)
This commit is contained in:
6
.devcontainer.json
Normal file
6
.devcontainer.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"dockerComposeFile": "compose.yaml",
|
||||
"initializeCommand": "docker volume create cabal-store",
|
||||
"service": "devcontainer",
|
||||
"workspaceFolder": "/workspaces/github-release"
|
||||
}
|
@@ -1,2 +0,0 @@
|
||||
FROM ghcr.io/tfausak/haskell-codespace:ghc-9.2
|
||||
RUN sudo apt-get update && sudo apt-get install --assume-yes zlib1g-dev
|
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile"
|
||||
},
|
||||
"postCreateCommand": "cabal update"
|
||||
}
|
12
.github/dependabot.yaml
vendored
Normal file
12
.github/dependabot.yaml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"updates": [
|
||||
{
|
||||
"directory": "/",
|
||||
"package-ecosystem": "github-actions",
|
||||
"schedule": {
|
||||
"interval": "daily"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version": 2
|
||||
}
|
10
.github/workflows/brittany.yaml
vendored
10
.github/workflows/brittany.yaml
vendored
@@ -1,10 +0,0 @@
|
||||
name: Brittany
|
||||
on: push
|
||||
jobs:
|
||||
brittany:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: tfausak/brittany-action@v1
|
||||
with:
|
||||
config: config/brittany.yaml
|
116
.github/workflows/ci.yaml
vendored
116
.github/workflows/ci.yaml
vendored
@@ -1,116 +0,0 @@
|
||||
name: CI
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
release:
|
||||
types:
|
||||
- created
|
||||
jobs:
|
||||
ci:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- { platform: ubuntu, ghc: 9.4.2 }
|
||||
- { platform: ubuntu, ghc: 9.2.1 }
|
||||
- { platform: macos, ghc: 9.2.1 }
|
||||
- { platform: windows, ghc: 9.2.1, extension: .exe }
|
||||
- { platform: ubuntu, ghc: 9.0.2 }
|
||||
runs-on: ${{ matrix.platform }}-latest
|
||||
name: GHC ${{ matrix.ghc }} on ${{ matrix.platform }}
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- id: artifact
|
||||
run: |
|
||||
mkdir artifact
|
||||
mkdir artifact/${{ matrix.platform }}
|
||||
mkdir artifact/${{ matrix.platform }}/${{ matrix.ghc }}
|
||||
echo '::set-output name=directory::artifact/${{ matrix.platform }}/${{ matrix.ghc }}'
|
||||
|
||||
- id: setup-haskell
|
||||
uses: haskell/actions/setup@v1
|
||||
with:
|
||||
ghc-version: ${{ matrix.ghc }}
|
||||
|
||||
- run: cabal configure --flags pedantic --jobs
|
||||
|
||||
- run: cabal freeze
|
||||
|
||||
- run: cat cabal.project.freeze
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.setup-haskell.outputs.cabal-store }}
|
||||
key: ${{ matrix.platform }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
|
||||
restore-keys: ${{ matrix.platform }}-${{ matrix.ghc }}-
|
||||
|
||||
- run: cabal build
|
||||
|
||||
- run: cabal install --install-method copy --installdir ${{ steps.artifact.outputs.directory }} .
|
||||
|
||||
- run: cabal check
|
||||
|
||||
- run: cabal sdist --output-dir ${{ steps.artifact.outputs.directory }}
|
||||
|
||||
- uses: svenstaro/upx-action@v2
|
||||
with:
|
||||
file: ${{ steps.artifact.outputs.directory }}/github-release${{ matrix.extension }}
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
path: artifact
|
||||
name: github-release-${{ github.sha }}
|
||||
|
||||
release:
|
||||
needs: ci
|
||||
if: github.event_name == 'release'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: github-release-${{ github.sha }}
|
||||
path: artifact
|
||||
|
||||
- uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
asset_content_type: application/octet-stream
|
||||
asset_name: github-release-${{ github.event.release.tag_name }}-ubuntu
|
||||
asset_path: artifact/ubuntu/9.2.1/github-release
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
|
||||
- uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
asset_content_type: application/octet-stream
|
||||
asset_name: github-release-${{ github.event.release.tag_name }}-macos
|
||||
asset_path: artifact/macos/9.2.1/github-release
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
|
||||
- uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
asset_content_type: application/octet-stream
|
||||
asset_name: github-release-${{ github.event.release.tag_name }}-windows.exe
|
||||
asset_path: artifact/windows/9.2.1/github-release.exe
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
|
||||
- uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
asset_content_type: application/gzip
|
||||
asset_name: github-release-${{ github.event.release.tag_name }}.tar.gz
|
||||
asset_path: artifact/ubuntu/9.2.1/github-release-${{ github.event.release.tag_name }}.tar.gz
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
|
||||
- run: cabal upload --publish --username '${{ secrets.HACKAGE_USERNAME }}' --password '${{ secrets.HACKAGE_PASSWORD }}' artifact/ubuntu/9.2.1/github-release-${{ github.event.release.tag_name }}.tar.gz
|
10
.github/workflows/hlint.yaml
vendored
10
.github/workflows/hlint.yaml
vendored
@@ -1,10 +0,0 @@
|
||||
name: HLint
|
||||
on: push
|
||||
jobs:
|
||||
hlint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: tfausak/hlint-action@v1
|
||||
with:
|
||||
config: config/hlint.yaml
|
220
.github/workflows/workflow.yaml
vendored
Normal file
220
.github/workflows/workflow.yaml
vendored
Normal file
@@ -0,0 +1,220 @@
|
||||
{
|
||||
"jobs": {
|
||||
"build": {
|
||||
"name": "Build on ${{ matrix.platform }} with GHC ${{ matrix.ghc }}",
|
||||
"runs-on": "${{ matrix.platform }}-${{ matrix.version }}",
|
||||
"steps": [
|
||||
{
|
||||
"uses": "actions/checkout@v3"
|
||||
},
|
||||
{
|
||||
"run": "mkdir artifact"
|
||||
},
|
||||
{
|
||||
"id": "artifact",
|
||||
"run": "echo 'directory=artifact/${{ matrix.platform }}-${{ matrix.ghc }}' >> $GITHUB_OUTPUT",
|
||||
"shell": "bash"
|
||||
},
|
||||
{
|
||||
"run": "mkdir ${{ steps.artifact.outputs.directory }}"
|
||||
},
|
||||
{
|
||||
"id": "haskell",
|
||||
"uses": "haskell/actions/setup@v2",
|
||||
"with": {
|
||||
"cabal-version": "3.8.1.0",
|
||||
"ghc-version": "${{ matrix.ghc }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"run": "cabal sdist --output-dir ${{ steps.artifact.outputs.directory }}"
|
||||
},
|
||||
{
|
||||
"run": "cabal configure --enable-optimization=2 --flags pedantic --jobs"
|
||||
},
|
||||
{
|
||||
"run": "cat cabal.project.local"
|
||||
},
|
||||
{
|
||||
"run": "cp cabal.project.local ${{ steps.artifact.outputs.directory }}"
|
||||
},
|
||||
{
|
||||
"run": "cabal freeze"
|
||||
},
|
||||
{
|
||||
"run": "cat cabal.project.freeze"
|
||||
},
|
||||
{
|
||||
"run": "cp cabal.project.freeze ${{ steps.artifact.outputs.directory }}"
|
||||
},
|
||||
{
|
||||
"run": "cabal outdated --v2-freeze-file cabal.project.freeze"
|
||||
},
|
||||
{
|
||||
"uses": "actions/cache@v3",
|
||||
"with": {
|
||||
"key": "${{ matrix.platform }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}",
|
||||
"path": "${{ steps.haskell.outputs.cabal-store }}",
|
||||
"restore-keys": "${{ matrix.platform }}-${{ matrix.ghc }}-"
|
||||
}
|
||||
},
|
||||
{
|
||||
"run": "cabal build --only-download"
|
||||
},
|
||||
{
|
||||
"run": "cabal build --only-dependencies"
|
||||
},
|
||||
{
|
||||
"run": "cabal build"
|
||||
},
|
||||
{
|
||||
"run": "cp \"$( cabal list-bin github-release )\" ${{ steps.artifact.outputs.directory }}"
|
||||
},
|
||||
{
|
||||
"uses": "svenstaro/upx-action@v2",
|
||||
"with": {
|
||||
"files": "${{ steps.artifact.outputs.directory }}/github-release${{ matrix.extension }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"uses": "actions/upload-artifact@v3",
|
||||
"with": {
|
||||
"name": "github-release-${{ github.sha }}",
|
||||
"path": "artifact"
|
||||
}
|
||||
}
|
||||
],
|
||||
"strategy": {
|
||||
"matrix": {
|
||||
"include": [
|
||||
{
|
||||
"ghc": "9.4.4",
|
||||
"platform": "macos",
|
||||
"version": "12"
|
||||
},
|
||||
{
|
||||
"ghc": "9.0.2",
|
||||
"platform": "ubuntu",
|
||||
"version": "22.04"
|
||||
},
|
||||
{
|
||||
"ghc": "9.2.5",
|
||||
"platform": "ubuntu",
|
||||
"version": "22.04"
|
||||
},
|
||||
{
|
||||
"ghc": "9.4.4",
|
||||
"platform": "ubuntu",
|
||||
"version": "22.04"
|
||||
},
|
||||
{
|
||||
"extension": ".exe",
|
||||
"ghc": "9.4.4",
|
||||
"platform": "windows",
|
||||
"version": "2022"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"cabal": {
|
||||
"name": "Cabal",
|
||||
"runs-on": "ubuntu-22.04",
|
||||
"steps": [
|
||||
{
|
||||
"uses": "actions/checkout@v3"
|
||||
},
|
||||
{
|
||||
"run": "cabal check"
|
||||
}
|
||||
]
|
||||
},
|
||||
"hlint": {
|
||||
"name": "HLint",
|
||||
"runs-on": "ubuntu-22.04",
|
||||
"steps": [
|
||||
{
|
||||
"uses": "actions/checkout@v3"
|
||||
},
|
||||
{
|
||||
"uses": "haskell/actions/hlint-setup@v2",
|
||||
"with": {
|
||||
"version": 3.5
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"ormolu": {
|
||||
"name": "Ormolu",
|
||||
"runs-on": "ubuntu-22.04",
|
||||
"steps": [
|
||||
{
|
||||
"uses": "actions/checkout@v3"
|
||||
},
|
||||
{
|
||||
"uses": "mrkkrp/ormolu-action@v10"
|
||||
}
|
||||
]
|
||||
},
|
||||
"release": {
|
||||
"if": "github.event_name == 'release'",
|
||||
"name": "Release",
|
||||
"needs": "build",
|
||||
"runs-on": "ubuntu-22.04",
|
||||
"steps": [
|
||||
{
|
||||
"uses": "actions/download-artifact@v3",
|
||||
"with": {
|
||||
"name": "github-release-${{ github.sha }}",
|
||||
"path": "artifact"
|
||||
}
|
||||
},
|
||||
{
|
||||
"uses": "svenstaro/upload-release-action@v2",
|
||||
"with": {
|
||||
"asset_name": "github-release-${{ github.event.release.tag_name }}-ubuntu",
|
||||
"file": "artifact/ubuntu-9.4.4/github-release"
|
||||
}
|
||||
},
|
||||
{
|
||||
"uses": "svenstaro/upload-release-action@v2",
|
||||
"with": {
|
||||
"asset_name": "github-release-${{ github.event.release.tag_name }}-macos",
|
||||
"file": "artifact/macos-9.4.4/github-release"
|
||||
}
|
||||
},
|
||||
{
|
||||
"uses": "svenstaro/upload-release-action@v2",
|
||||
"with": {
|
||||
"asset_name": "github-release-${{ github.event.release.tag_name }}-windows.exe",
|
||||
"file": "artifact/windows-9.4.4/github-release.exe"
|
||||
}
|
||||
},
|
||||
{
|
||||
"uses": "svenstaro/upload-release-action@v2",
|
||||
"with": {
|
||||
"asset_name": "github-release-${{ github.event.release.tag_name }}.tar.gz",
|
||||
"file": "artifact/ubuntu-9.4.4/github-release-${{ github.event.release.tag_name }}.tar.gz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"run": "cabal upload --publish --username '${{ secrets.HACKAGE_USERNAME }}' --password '${{ secrets.HACKAGE_PASSWORD }}' artifact/ubuntu-9.4.4/github-release-${{ github.event.release.tag_name }}.tar.gz"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"name": "Workflow",
|
||||
"on": {
|
||||
"push": null,
|
||||
"release": {
|
||||
"types": [
|
||||
"created"
|
||||
]
|
||||
},
|
||||
"schedule": [
|
||||
{
|
||||
"cron": "0 0 * * *"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,5 +1,3 @@
|
||||
/.stack-work/
|
||||
/cabal.project.freeze
|
||||
/cabal.project.local*
|
||||
/.vscode/
|
||||
/cabal.project.*
|
||||
/dist-newstyle/
|
||||
/stack.yaml.lock
|
||||
|
24
.hlint.yaml
Normal file
24
.hlint.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
[
|
||||
{
|
||||
"group": {
|
||||
"enabled": true,
|
||||
"name": "dollar"
|
||||
}
|
||||
},
|
||||
{
|
||||
"group": {
|
||||
"enabled": true,
|
||||
"name": "generalise"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ignore": {
|
||||
"name": "Use lambda-case"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ignore": {
|
||||
"name": "Use tuple-section"
|
||||
}
|
||||
}
|
||||
]
|
5
.vscode/extensions.json
vendored
5
.vscode/extensions.json
vendored
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"taylorfausak.purple-yolk"
|
||||
]
|
||||
}
|
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"purple-yolk.brittany.command": "brittany --config-file config/brittany.yaml --write-mode inplace",
|
||||
"purple-yolk.ghci.command": "cabal repl --repl-options -ddump-json",
|
||||
"purple-yolk.hlint.command": "hlint --hint config/hlint.yaml --json --no-exit-code",
|
||||
"purple-yolk.hlint.onSave": true
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Taylor Fausak
|
||||
Copyright (c) 2023 Taylor Fausak
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -1,7 +1 @@
|
||||
packages: .
|
||||
|
||||
-- https://github.com/vincenthz/hs-memory/pull/93
|
||||
source-repository-package
|
||||
location: https://github.com/parsonsmatt/hs-memory
|
||||
tag: 696383fbfb334c9247f9b406e1489b9ab294927d
|
||||
type: git
|
||||
|
21
compose.yaml
Normal file
21
compose.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"services": {
|
||||
"devcontainer": {
|
||||
"command": "sh -c 'while sleep 1; do :; done'",
|
||||
"image": "public.ecr.aws/acilearning/haskell:9.4.4",
|
||||
"init": true,
|
||||
"volumes": [
|
||||
".:/workspaces/github-release",
|
||||
"cabal:/home/haskell/.cabal",
|
||||
"cabal-store:/cabal-store"
|
||||
],
|
||||
"working_dir": "/workspaces/github-release"
|
||||
}
|
||||
},
|
||||
"volumes": {
|
||||
"cabal": null,
|
||||
"cabal-store": {
|
||||
"external": true
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +0,0 @@
|
||||
conf_layout:
|
||||
lconfig_cols: 79
|
||||
lconfig_columnAlignMode: { tag: ColumnAlignModeDisabled }
|
||||
lconfig_indentPolicy: IndentPolicyLeft
|
@@ -1,4 +0,0 @@
|
||||
- group: { name: dollar, enabled: true }
|
||||
- group: { name: generalise, enabled: true }
|
||||
- ignore: { name: Use lambda-case }
|
||||
- ignore: { name: Use tuple-section }
|
@@ -24,39 +24,36 @@ flag pedantic
|
||||
|
||||
common library
|
||||
build-depends:
|
||||
, base >= 4.13.0 && < 4.18
|
||||
, base >= 4.15.0 && < 4.18
|
||||
, aeson >= 1.4.7 && < 1.6 || >= 2.0.0 && < 2.2
|
||||
, burrito >= 1.2.0 && < 1.3 || >= 2.0.0 && < 2.1
|
||||
, bytestring >= 0.10.10 && < 0.12
|
||||
, bytestring >= 0.10.12 && < 0.12
|
||||
, http-client >= 0.6.4 && < 0.8
|
||||
, http-client-tls >= 0.3.5 && < 0.4
|
||||
, http-types >= 0.12.3 && < 0.13
|
||||
, mime-types >= 0.1.0 && < 0.2
|
||||
, optparse-generic >= 1.3.1 && < 1.5
|
||||
, text >= 1.2.4 && < 1.3 || >= 2.0 && < 2.1
|
||||
, text >= 1.2.5 && < 1.3 || >= 2.0 && < 2.1
|
||||
, unordered-containers >= 0.2.10 && < 0.3
|
||||
default-language: Haskell2010
|
||||
ghc-options:
|
||||
-Weverything
|
||||
-Wno-all-missed-specialisations
|
||||
-Wno-implicit-prelude
|
||||
-Wno-missing-deriving-strategies
|
||||
-Wno-missing-exported-signatures
|
||||
-Wno-missing-safe-haskell-mode
|
||||
-Wno-prepositive-qualified-module
|
||||
-Wno-safe
|
||||
-Wno-unsafe
|
||||
-Wno-all-missed-specialisations
|
||||
|
||||
if flag(pedantic)
|
||||
ghc-options: -Werror
|
||||
|
||||
if impl(ghc >= 8.10)
|
||||
ghc-options:
|
||||
-Wno-missing-safe-haskell-mode
|
||||
-Wno-prepositive-qualified-module
|
||||
|
||||
if impl(ghc >= 9.2)
|
||||
ghc-options:
|
||||
-Wno-missing-kind-signatures
|
||||
|
||||
if flag(pedantic)
|
||||
ghc-options: -Werror
|
||||
|
||||
common executable
|
||||
import: library
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
module Main
|
||||
( module GitHubRelease
|
||||
) where
|
||||
( module GitHubRelease,
|
||||
)
|
||||
where
|
||||
|
||||
import GitHubRelease (main)
|
||||
|
@@ -1,30 +1,28 @@
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# OPTIONS_GHC -Wno-partial-fields #-}
|
||||
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
|
||||
module GitHubRelease
|
||||
( Command(..)
|
||||
, main
|
||||
, runCommand
|
||||
, upload
|
||||
, getUploadUrl
|
||||
, getTag
|
||||
, authorizationHeader
|
||||
, userAgentHeader
|
||||
, userAgent
|
||||
, versionString
|
||||
, uploadFile
|
||||
, uploadBody
|
||||
) where
|
||||
|
||||
import Options.Generic (type (<?>))
|
||||
( Command (..),
|
||||
main,
|
||||
runCommand,
|
||||
upload,
|
||||
getUploadUrl,
|
||||
getTag,
|
||||
authorizationHeader,
|
||||
userAgentHeader,
|
||||
userAgent,
|
||||
versionString,
|
||||
uploadFile,
|
||||
uploadBody,
|
||||
)
|
||||
where
|
||||
|
||||
import qualified Burrito
|
||||
import Data.Aeson ((.=), object)
|
||||
import Data.Aeson (object, (.=))
|
||||
import qualified Data.Aeson as Aeson
|
||||
import qualified Data.ByteString.Char8 as BS8
|
||||
import qualified Data.ByteString.Lazy as BSL
|
||||
@@ -37,6 +35,7 @@ import qualified Network.HTTP.Client as Client
|
||||
import qualified Network.HTTP.Client.TLS as TLS
|
||||
import qualified Network.HTTP.Types as HTTP
|
||||
import qualified Network.Mime as MIME
|
||||
import Options.Generic (type (<?>))
|
||||
import qualified Options.Generic as Options
|
||||
import qualified Paths_github_release as This
|
||||
import qualified System.Environment as Environment
|
||||
@@ -44,28 +43,31 @@ import qualified System.IO as IO
|
||||
import qualified Text.Printf as Printf
|
||||
|
||||
data Command
|
||||
= Upload { file :: FilePath <?> "The path to the local file to upload."
|
||||
, name :: String <?> "The name to give the file on the release."
|
||||
, owner :: Maybe String <?> "The GitHub owner, either a user or organization."
|
||||
, repo :: String <?> "The GitHub repository name."
|
||||
, tag :: String <?> "The tag name."
|
||||
, token :: Maybe String <?> "Your OAuth2 token."}
|
||||
| Release { title :: String <?> "The name of the release"
|
||||
, owner :: Maybe String <?> "The GitHub owner, either a user or organization."
|
||||
, repo :: String <?> "The GitHub repository name."
|
||||
, tag :: String <?> "The tag name."
|
||||
, description :: Maybe String <?> "Release description."
|
||||
, token :: Maybe String <?> "Your OAuth2 token."
|
||||
, preRelease :: Maybe Bool <?> "Indicates if this is a pre-release."
|
||||
, draft :: Maybe Bool <?> "Indicates if this is a draft."
|
||||
}
|
||||
= Upload
|
||||
{ file :: FilePath <?> "The path to the local file to upload.",
|
||||
name :: String <?> "The name to give the file on the release.",
|
||||
owner :: Maybe String <?> "The GitHub owner, either a user or organization.",
|
||||
repo :: String <?> "The GitHub repository name.",
|
||||
tag :: String <?> "The tag name.",
|
||||
token :: Maybe String <?> "Your OAuth2 token."
|
||||
}
|
||||
| Release
|
||||
{ title :: String <?> "The name of the release",
|
||||
owner :: Maybe String <?> "The GitHub owner, either a user or organization.",
|
||||
repo :: String <?> "The GitHub repository name.",
|
||||
tag :: String <?> "The tag name.",
|
||||
description :: Maybe String <?> "Release description.",
|
||||
token :: Maybe String <?> "Your OAuth2 token.",
|
||||
preRelease :: Maybe Bool <?> "Indicates if this is a pre-release.",
|
||||
draft :: Maybe Bool <?> "Indicates if this is a draft."
|
||||
}
|
||||
| Delete
|
||||
{ name :: String <?> "The name to give the file on the release."
|
||||
, owner :: Maybe String <?> "The GitHub owner, either a user or organization."
|
||||
, repo :: String <?> "The GitHub repository name."
|
||||
, tag :: String <?> "The tag name."
|
||||
, token :: Maybe String <?> "Your OAuth2 token."
|
||||
}
|
||||
{ name :: String <?> "The name to give the file on the release.",
|
||||
owner :: Maybe String <?> "The GitHub owner, either a user or organization.",
|
||||
repo :: String <?> "The GitHub repository name.",
|
||||
tag :: String <?> "The tag name.",
|
||||
token :: Maybe String <?> "Your OAuth2 token."
|
||||
}
|
||||
| Version
|
||||
deriving (Generics.Generic, Show)
|
||||
|
||||
@@ -79,8 +81,9 @@ main = do
|
||||
runCommand :: Command -> IO ()
|
||||
runCommand command = case command of
|
||||
Upload aFile aName anOwner aRepo aTag helpfulToken -> do
|
||||
aToken <- maybe (Environment.getEnv "GITHUB_TOKEN") pure
|
||||
$ Options.unHelpful helpfulToken
|
||||
aToken <-
|
||||
maybe (Environment.getEnv "GITHUB_TOKEN") pure $
|
||||
Options.unHelpful helpfulToken
|
||||
upload
|
||||
aToken
|
||||
(Options.unHelpful anOwner)
|
||||
@@ -88,10 +91,11 @@ runCommand command = case command of
|
||||
(Options.unHelpful aTag)
|
||||
(Options.unHelpful aFile)
|
||||
(Options.unHelpful aName)
|
||||
Release aTitle anOwner aRepo aTag aDescription helpfulToken aPreRelease aDraft
|
||||
-> do
|
||||
aToken <- maybe (Environment.getEnv "GITHUB_TOKEN") pure
|
||||
$ Options.unHelpful helpfulToken
|
||||
Release aTitle anOwner aRepo aTag aDescription helpfulToken aPreRelease aDraft ->
|
||||
do
|
||||
aToken <-
|
||||
maybe (Environment.getEnv "GITHUB_TOKEN") pure $
|
||||
Options.unHelpful helpfulToken
|
||||
release
|
||||
aToken
|
||||
(Options.unHelpful anOwner)
|
||||
@@ -102,8 +106,9 @@ runCommand command = case command of
|
||||
(Options.unHelpful aPreRelease)
|
||||
(Options.unHelpful aDraft)
|
||||
Delete aName anOwner aRepo aTag helpfulToken -> do
|
||||
aToken <- maybe (Environment.getEnv "GITHUB_TOKEN") pure
|
||||
$ Options.unHelpful helpfulToken
|
||||
aToken <-
|
||||
maybe (Environment.getEnv "GITHUB_TOKEN") pure $
|
||||
Options.unHelpful helpfulToken
|
||||
delete
|
||||
(Options.unHelpful aName)
|
||||
(Options.unHelpful anOwner)
|
||||
@@ -112,8 +117,8 @@ runCommand command = case command of
|
||||
aToken
|
||||
Version -> putStrLn versionString
|
||||
|
||||
upload
|
||||
:: String -> Maybe String -> String -> String -> FilePath -> String -> IO ()
|
||||
upload ::
|
||||
String -> Maybe String -> String -> String -> FilePath -> String -> IO ()
|
||||
upload aToken anOwner aRepo aTag aFile aName = do
|
||||
manager <- Client.newManager TLS.tlsManagerSettings
|
||||
uploadUrl <- getUploadUrl manager aToken anOwner aRepo aTag
|
||||
@@ -122,37 +127,37 @@ upload aToken anOwner aRepo aTag aFile aName = do
|
||||
201 -> pure ()
|
||||
_ -> fail "Failed to upload file to release!"
|
||||
|
||||
release
|
||||
:: String
|
||||
-> Maybe String
|
||||
-> String
|
||||
-> String
|
||||
-> String
|
||||
-> Maybe String
|
||||
-> Maybe Bool
|
||||
-> Maybe Bool
|
||||
-> IO ()
|
||||
release ::
|
||||
String ->
|
||||
Maybe String ->
|
||||
String ->
|
||||
String ->
|
||||
String ->
|
||||
Maybe String ->
|
||||
Maybe Bool ->
|
||||
Maybe Bool ->
|
||||
IO ()
|
||||
release aToken anOwner aRepo aTag aTitle aDescription aPreRelease aDraft = do
|
||||
manager <- Client.newManager TLS.tlsManagerSettings
|
||||
(owner', repo') <- getOwnerRepo anOwner aRepo
|
||||
let format = "https://api.github.com/repos/%s/%s/releases" :: String
|
||||
let
|
||||
url :: String
|
||||
url = Printf.printf format owner' repo'
|
||||
response <- mkRelease
|
||||
manager
|
||||
url
|
||||
aToken
|
||||
aTag
|
||||
aTitle
|
||||
aDescription
|
||||
aPreRelease
|
||||
aDraft
|
||||
let
|
||||
body =
|
||||
Aeson.eitherDecode $ Client.responseBody response :: Either
|
||||
String
|
||||
Aeson.Object
|
||||
let url :: String
|
||||
url = Printf.printf format owner' repo'
|
||||
response <-
|
||||
mkRelease
|
||||
manager
|
||||
url
|
||||
aToken
|
||||
aTag
|
||||
aTitle
|
||||
aDescription
|
||||
aPreRelease
|
||||
aDraft
|
||||
let body =
|
||||
Aeson.eitherDecode $ Client.responseBody response ::
|
||||
Either
|
||||
String
|
||||
Aeson.Object
|
||||
case HTTP.statusCode (Client.responseStatus response) of
|
||||
201 -> pure ()
|
||||
422 -> IO.hPutStrLn IO.stderr "Release aready exists. Ignoring."
|
||||
@@ -171,42 +176,44 @@ delete aName rawOwner rawRepo aTag aToken = do
|
||||
[] -> fail "Failed to find asset on release."
|
||||
ghAsset : _ -> do
|
||||
request <- Client.parseRequest $ ghAssetUrl ghAsset
|
||||
response <- Client.httpLbs
|
||||
request
|
||||
{ Client.method = HTTP.methodDelete
|
||||
, Client.requestHeaders =
|
||||
[authorizationHeader aToken, userAgentHeader]
|
||||
}
|
||||
manager
|
||||
response <-
|
||||
Client.httpLbs
|
||||
request
|
||||
{ Client.method = HTTP.methodDelete,
|
||||
Client.requestHeaders =
|
||||
[authorizationHeader aToken, userAgentHeader]
|
||||
}
|
||||
manager
|
||||
case HTTP.statusCode $ Client.responseStatus response of
|
||||
204 -> pure ()
|
||||
_ -> fail $ "Failed to delete asset from release! " <> show response
|
||||
|
||||
newtype GHRelease = GHRelease
|
||||
{ ghReleaseAssets :: [GHAsset]
|
||||
} deriving (Eq, Show)
|
||||
}
|
||||
deriving (Eq, Show)
|
||||
|
||||
instance Aeson.FromJSON GHRelease where
|
||||
parseJSON =
|
||||
Aeson.withObject "GHRelease" $ \obj -> GHRelease <$> obj Aeson..: "assets"
|
||||
|
||||
data GHAsset = GHAsset
|
||||
{ ghAssetName :: String
|
||||
, ghAssetUrl :: String
|
||||
{ ghAssetName :: String,
|
||||
ghAssetUrl :: String
|
||||
}
|
||||
deriving (Eq, Show)
|
||||
|
||||
instance Aeson.FromJSON GHAsset where
|
||||
parseJSON = Aeson.withObject "GHAsset"
|
||||
$ \obj -> GHAsset <$> obj Aeson..: "name" <*> obj Aeson..: "url"
|
||||
parseJSON = Aeson.withObject "GHAsset" $
|
||||
\obj -> GHAsset <$> obj Aeson..: "name" <*> obj Aeson..: "url"
|
||||
|
||||
getUploadUrl
|
||||
:: Client.Manager
|
||||
-> String
|
||||
-> Maybe String
|
||||
-> String
|
||||
-> String
|
||||
-> IO Burrito.Template
|
||||
getUploadUrl ::
|
||||
Client.Manager ->
|
||||
String ->
|
||||
Maybe String ->
|
||||
String ->
|
||||
String ->
|
||||
IO Burrito.Template
|
||||
getUploadUrl manager aToken rawOwner rawRepo aTag = do
|
||||
json <- do
|
||||
(anOwner, aRepo) <- getOwnerRepo rawOwner rawRepo
|
||||
@@ -235,24 +242,23 @@ getOwnerRepo rawOwner rawRepo = do
|
||||
pure (anOwner, drop 1 aRepo)
|
||||
return (anOwner, aRepo)
|
||||
|
||||
getTag
|
||||
:: Aeson.FromJSON a
|
||||
=> Client.Manager
|
||||
-> String
|
||||
-> String
|
||||
-> String
|
||||
-> String
|
||||
-> IO (Either String a)
|
||||
getTag ::
|
||||
(Aeson.FromJSON a) =>
|
||||
Client.Manager ->
|
||||
String ->
|
||||
String ->
|
||||
String ->
|
||||
String ->
|
||||
IO (Either String a)
|
||||
getTag manager aToken anOwner aRepo aTag = do
|
||||
let format = "https://api.github.com/repos/%s/%s/releases/tags/%s" :: String
|
||||
let
|
||||
url :: String
|
||||
url = Printf.printf format anOwner aRepo aTag
|
||||
let url :: String
|
||||
url = Printf.printf format anOwner aRepo aTag
|
||||
initialRequest <- Client.parseRequest url
|
||||
let
|
||||
request = initialRequest
|
||||
{ Client.requestHeaders = [authorizationHeader aToken, userAgentHeader]
|
||||
}
|
||||
let request =
|
||||
initialRequest
|
||||
{ Client.requestHeaders = [authorizationHeader aToken, userAgentHeader]
|
||||
}
|
||||
response <- Client.httpLbs request manager
|
||||
let body = Client.responseBody response
|
||||
return (Aeson.eitherDecode body)
|
||||
@@ -265,75 +271,75 @@ userAgentHeader :: HTTP.Header
|
||||
userAgentHeader = (HTTP.hUserAgent, BS8.pack userAgent)
|
||||
|
||||
userAgent :: String
|
||||
userAgent = Printf.printf
|
||||
"%s/%s-%s"
|
||||
("tfausak" :: String)
|
||||
("github-release" :: String)
|
||||
versionString
|
||||
userAgent =
|
||||
Printf.printf
|
||||
"%s/%s-%s"
|
||||
("tfausak" :: String)
|
||||
("github-release" :: String)
|
||||
versionString
|
||||
|
||||
versionString :: String
|
||||
versionString = Version.showVersion This.version
|
||||
|
||||
uploadFile
|
||||
:: Client.Manager
|
||||
-> Burrito.Template
|
||||
-> String
|
||||
-> FilePath
|
||||
-> String
|
||||
-> IO (Client.Response BSL.ByteString)
|
||||
uploadFile ::
|
||||
Client.Manager ->
|
||||
Burrito.Template ->
|
||||
String ->
|
||||
FilePath ->
|
||||
String ->
|
||||
IO (Client.Response BSL.ByteString)
|
||||
uploadFile manager template aToken aFile aName = do
|
||||
contents <- BSL.readFile aFile
|
||||
let body = Client.RequestBodyLBS contents
|
||||
uploadBody manager template aToken body aName
|
||||
|
||||
uploadBody
|
||||
:: Client.Manager
|
||||
-> Burrito.Template
|
||||
-> String
|
||||
-> Client.RequestBody
|
||||
-> String
|
||||
-> IO (Client.Response BSL.ByteString)
|
||||
uploadBody ::
|
||||
Client.Manager ->
|
||||
Burrito.Template ->
|
||||
String ->
|
||||
Client.RequestBody ->
|
||||
String ->
|
||||
IO (Client.Response BSL.ByteString)
|
||||
uploadBody manager template aToken body aName = do
|
||||
let
|
||||
url :: String
|
||||
url = Burrito.expand [("name", Burrito.stringValue aName)] template
|
||||
let url :: String
|
||||
url = Burrito.expand [("name", Burrito.stringValue aName)] template
|
||||
initialRequest <- Client.parseRequest url
|
||||
let
|
||||
request = initialRequest
|
||||
{ Client.method = BS8.pack "POST"
|
||||
, Client.requestBody = body
|
||||
, Client.requestHeaders =
|
||||
[ authorizationHeader aToken
|
||||
, (HTTP.hContentType, MIME.defaultMimeLookup (Text.pack aName))
|
||||
, userAgentHeader
|
||||
]
|
||||
}
|
||||
let request =
|
||||
initialRequest
|
||||
{ Client.method = BS8.pack "POST",
|
||||
Client.requestBody = body,
|
||||
Client.requestHeaders =
|
||||
[ authorizationHeader aToken,
|
||||
(HTTP.hContentType, MIME.defaultMimeLookup (Text.pack aName)),
|
||||
userAgentHeader
|
||||
]
|
||||
}
|
||||
Client.httpLbs request manager
|
||||
|
||||
mkRelease
|
||||
:: Client.Manager
|
||||
-> String
|
||||
-> String
|
||||
-> String
|
||||
-> String
|
||||
-> Maybe String
|
||||
-> Maybe Bool
|
||||
-> Maybe Bool
|
||||
-> IO (Client.Response BSL.ByteString)
|
||||
mkRelease ::
|
||||
Client.Manager ->
|
||||
String ->
|
||||
String ->
|
||||
String ->
|
||||
String ->
|
||||
Maybe String ->
|
||||
Maybe Bool ->
|
||||
Maybe Bool ->
|
||||
IO (Client.Response BSL.ByteString)
|
||||
mkRelease manager url aToken aTag aTitle aDescription aPreRelease aDraft = do
|
||||
initialRequest <- Client.parseRequest url
|
||||
let
|
||||
requestObject = object
|
||||
[ "tag_name" .= aTag
|
||||
, "name" .= aTitle
|
||||
, "body" .= Maybe.fromMaybe "" aDescription
|
||||
, "prerelease" .= Maybe.fromMaybe False aPreRelease
|
||||
, "draft" .= Maybe.fromMaybe False aDraft
|
||||
]
|
||||
let
|
||||
request = initialRequest
|
||||
{ Client.method = BS8.pack "POST"
|
||||
, Client.requestBody = Client.RequestBodyLBS $ Aeson.encode requestObject
|
||||
, Client.requestHeaders = [authorizationHeader aToken, userAgentHeader]
|
||||
}
|
||||
let requestObject =
|
||||
object
|
||||
[ "tag_name" .= aTag,
|
||||
"name" .= aTitle,
|
||||
"body" .= Maybe.fromMaybe "" aDescription,
|
||||
"prerelease" .= Maybe.fromMaybe False aPreRelease,
|
||||
"draft" .= Maybe.fromMaybe False aDraft
|
||||
]
|
||||
let request =
|
||||
initialRequest
|
||||
{ Client.method = BS8.pack "POST",
|
||||
Client.requestBody = Client.RequestBodyLBS $ Aeson.encode requestObject,
|
||||
Client.requestHeaders = [authorizationHeader aToken, userAgentHeader]
|
||||
}
|
||||
Client.httpLbs request manager
|
||||
|
@@ -1 +0,0 @@
|
||||
resolver: lts-17.0
|
Reference in New Issue
Block a user