ci: Fix triggering events and release actions
* Run CI only on pull requests, push to main and push to tags matching v*. This avoids running the CI more than once for a single user action * Change pre-releases, which are now identified by a version number with 4 components (e.g., 1.1.1.1) * Change how release artifacts are packaged, ensuring they are executable and compressed with xz
This commit is contained in:
+30
-15
@@ -1,7 +1,14 @@
|
|||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
- push
|
push:
|
||||||
- pull_request
|
branches:
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Lint-Style:
|
Lint-Style:
|
||||||
@@ -236,10 +243,10 @@ jobs:
|
|||||||
echo "::set-output name=version::$cabal_version"
|
echo "::set-output name=version::$cabal_version"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$cabal_version" != *-* ]]; then
|
if [[ "$cabal_version" != *.*.*.* ]]; then
|
||||||
echo "Version is for a full release (no '-' in version)"
|
echo "Version is for a full release (version does not have four components)"
|
||||||
else
|
else
|
||||||
echo "Version is for a pre-release (version contains a '-', as in v1.0.0-a2)"
|
echo "Version is for a pre-release (version has four components, e.g., 1.1.1.1)"
|
||||||
echo "::set-output name=isprerelease::1"
|
echo "::set-output name=isprerelease::1"
|
||||||
fi
|
fi
|
||||||
- name: Identify changes from CHANGELOG.md
|
- name: Identify changes from CHANGELOG.md
|
||||||
@@ -279,22 +286,24 @@ jobs:
|
|||||||
path: artifacts
|
path: artifacts
|
||||||
- name: Create release bundle with archives for all builds
|
- name: Create release bundle with archives for all builds
|
||||||
run: |
|
run: |
|
||||||
|
find artifacts -type f -iname postgrest -exec chmod +x {} \;
|
||||||
|
|
||||||
mkdir -p release-bundle
|
mkdir -p release-bundle
|
||||||
|
|
||||||
tar cfvz "release-bundle/postgrest-v$VERSION-linux-static-x64.tar.gz" \
|
tar cJvf "release-bundle/postgrest-v$VERSION-linux-static-x64.tar.xz" \
|
||||||
-C artifacts/postgrest-linux-static-x64 postgrest
|
-C artifacts/postgrest-linux-static-x64 postgrest
|
||||||
|
|
||||||
# No need to release Ubuntu, as the static Linux binary built with Nix
|
# No need to release Ubuntu, as the static Linux binary built with Nix
|
||||||
# covers all Linux use-cases
|
# covers all Linux use-cases
|
||||||
#tar cfvz "release-bundle/postgrest-v$VERSION-ubuntu-x64.tar.gz" \
|
#tar cfJv "release-bundle/postgrest-v$VERSION-ubuntu-x64.tar.xz" \
|
||||||
# -C artifacts/postgrest-ubuntu-x64 postgrest
|
# -C artifacts/postgrest-ubuntu-x64 postgrest
|
||||||
|
|
||||||
tar cfvz "release-bundle/postgrest-v$VERSION-macos-x64.tar.gz" \
|
tar cJvf "release-bundle/postgrest-v$VERSION-macos-x64.tar.xz" \
|
||||||
-C artifacts/postgrest-macos-x64 postgrest
|
-C artifacts/postgrest-macos-x64 postgrest
|
||||||
|
|
||||||
tar cfvz "release-bundle/postgrest-v$VERSION-freebsd-x64.tar.gz" \
|
tar cJvf "release-bundle/postgrest-v$VERSION-freebsd-x64.tar.xz" \
|
||||||
-C artifacts/postgrest-freebsd-x64 postgrest
|
-C artifacts/postgrest-freebsd-x64 postgrest
|
||||||
|
|
||||||
zip "release-bundle/postgrest-v$VERSION-windows-x64.zip" \
|
zip "release-bundle/postgrest-v$VERSION-windows-x64.zip" \
|
||||||
artifacts/postgrest-windows-x64/postgrest.exe
|
artifacts/postgrest-windows-x64/postgrest.exe
|
||||||
|
|
||||||
@@ -317,7 +326,7 @@ jobs:
|
|||||||
-F artifacts/release-changes/CHANGES.md \
|
-F artifacts/release-changes/CHANGES.md \
|
||||||
${isprerelease:+"--prerelease"} \
|
${isprerelease:+"--prerelease"} \
|
||||||
release-bundle/*
|
release-bundle/*
|
||||||
|
|
||||||
Release-Docker:
|
Release-Docker:
|
||||||
name: Release on Docker Hub
|
name: Release on Docker Hub
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -355,4 +364,10 @@ jobs:
|
|||||||
- name: Update descriptions on Docker Hub
|
- name: Update descriptions on Docker Hub
|
||||||
env:
|
env:
|
||||||
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
|
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
|
||||||
run: postgrest-release-dockerhub-description
|
run: |
|
||||||
|
if [[ -z "$ISPRERELEASE" ]]; then
|
||||||
|
echo "Updating description on Docker Hub..."
|
||||||
|
postgrest-release-dockerhub-description
|
||||||
|
else
|
||||||
|
echo "Skipping updating description for pre-release..."
|
||||||
|
fi
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
name: postgrest
|
name: postgrest
|
||||||
version: 9.0.0-a1
|
version: 8.0.0.20210921
|
||||||
synopsis: REST API for any Postgres database
|
synopsis: REST API for any Postgres database
|
||||||
description: Reads the schema of a PostgreSQL database and creates RESTful routes
|
description: Reads the schema of a PostgreSQL database and creates RESTful routes
|
||||||
for the tables and views, supporting all HTTP verbs that security
|
for the tables and views, supporting all HTTP verbs that security
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
{-# OPTIONS_GHC -fno-warn-type-defaults #-}
|
|
||||||
module PostgREST.Version
|
module PostgREST.Version
|
||||||
( docsVersion
|
( docsVersion
|
||||||
, prettyVersion
|
, prettyVersion
|
||||||
@@ -7,23 +6,36 @@ module PostgREST.Version
|
|||||||
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
|
||||||
import Data.Version (versionBranch)
|
import Data.Version (showVersion, versionBranch)
|
||||||
import Development.GitRev (gitHash)
|
import Development.GitRev (gitHash)
|
||||||
import Paths_postgrest (version)
|
import Paths_postgrest (version)
|
||||||
|
|
||||||
import Protolude
|
import Protolude
|
||||||
|
|
||||||
|
|
||||||
-- | User friendly version number
|
-- | User friendly version number such as '1.1.1'.
|
||||||
|
-- Pre-release versions are tagged as such, e.g., '1.1.1.1 (pre-release)'.
|
||||||
|
-- If a git hash is available, it's added to the version, e.g., '1.1.1 (abcdef0)'.
|
||||||
prettyVersion :: Text
|
prettyVersion :: Text
|
||||||
prettyVersion =
|
prettyVersion =
|
||||||
T.intercalate "." (map show $ versionBranch version) <> gitRev
|
T.pack (showVersion version) <> preRelease <> gitRev
|
||||||
where
|
where
|
||||||
gitRev =
|
gitRev =
|
||||||
if $(gitHash) == "UNKNOWN"
|
if $(gitHash) == ("UNKNOWN" :: Text) then
|
||||||
then mempty
|
mempty
|
||||||
else " (" <> T.take 7 $(gitHash) <> ")"
|
else
|
||||||
|
" (" <> T.take 7 $(gitHash) <> ")"
|
||||||
|
preRelease = if isPreRelease then " (pre-release)" else mempty
|
||||||
|
|
||||||
-- | Version number used in docs
|
|
||||||
|
-- | Version number used in docs.
|
||||||
|
-- Uses only the two first components of the version. Example: 'v1.1'
|
||||||
docsVersion :: Text
|
docsVersion :: Text
|
||||||
docsVersion = "v" <> T.dropEnd 1 (T.dropWhileEnd (/= '.') prettyVersion)
|
docsVersion =
|
||||||
|
"v" <> (T.intercalate "." . map show . take 2 $ versionBranch version)
|
||||||
|
|
||||||
|
|
||||||
|
-- | Versions with four components (e.g., '1.1.1.1') are treated as pre-releases.
|
||||||
|
isPreRelease :: Bool
|
||||||
|
isPreRelease =
|
||||||
|
length (versionBranch version) == 4
|
||||||
|
|||||||
Reference in New Issue
Block a user