3636 id : set-versions
3737 run : |
3838 VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[]' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c 'split("\n")[:-1]')
39- echo "postgres_versions=$VERSIONS" >> " $GITHUB_OUTPUT"
39+ echo "postgres_versions=$VERSIONS" >> $GITHUB_OUTPUT
4040
4141 build :
4242 needs : prepare
@@ -67,21 +67,25 @@ jobs:
6767 substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com
6868 trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
6969
70+ - name : Run checks if triggered manually
71+ if : ${{ github.event_name == 'workflow_dispatch' }}
72+ run : |
73+ SUFFIX=$(nix run nixpkgs#yq -- ".postgres_release[\"postgres${{ matrix.postgres_version }}\"]" ansible/vars.yml | sed -E 's/[0-9\.]+(.*)$/\1/')
74+ if [[ -z "$SUFFIX" ]] ; then
75+ echo "Version must include non-numeric characters if built manually."
76+ exit 1
77+ fi
78+
7079 - name : Set PostgreSQL version environment variable
7180 run : |
72- echo "POSTGRES_MAJOR_VERSION=${{ matrix.postgres_version }}" >> " $GITHUB_ENV"
73- echo "EXECUTION_ID=${{ github.run_id }}-${{ matrix.postgres_version }}" >> " $GITHUB_ENV"
81+ echo "POSTGRES_MAJOR_VERSION=${{ matrix.postgres_version }}" >> $GITHUB_ENV
82+ echo "EXECUTION_ID=${{ github.run_id }}-${{ matrix.postgres_version }}" >> $GITHUB_ENV
7483
7584 - name : Generate common-nix.vars.pkr.hcl
7685 run : |
77- PG_VERSION="$(nix run nixpkgs#yq -- -r '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)"
78- BRANCH_NAME="$(echo "${{ github.ref }}" | sed 's|refs/heads/||')"
79- if [[ "${{ github.event_name }}" == "workflow_dispatch" && "$BRANCH_NAME" != "develop" && "$BRANCH_NAME" != release/* ]]; then
80- SUFFIX="${BRANCH_NAME//[^a-zA-Z0-9._-]/-}-${{ github.run_id }}"
81- PG_VERSION="${PG_VERSION}-${SUFFIX}"
82- echo "Added branch suffix to version: $SUFFIX"
83- fi
84- echo "postgres-version = \"$PG_VERSION\"" > common-nix.vars.pkr.hcl
86+ PG_VERSION=$(nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
87+ PG_VERSION=$(echo "$PG_VERSION" | tr -d '"') # Remove any surrounding quotes
88+ echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl
8589 # Ensure there's a newline at the end of the file
8690 echo "" >> common-nix.vars.pkr.hcl
8791
@@ -106,9 +110,8 @@ jobs:
106110 - name : Grab release version
107111 id : process_release_version
108112 run : |
109- VERSION=$(sed -e 's/postgres-version = "\(.*\)"/\1/g' common-nix.vars.pkr.hcl)
110- echo "version=$VERSION" >> "$GITHUB_OUTPUT"
111- echo "::notice title=AMI Published::Postgres AMI version: $VERSION"
113+ VERSION=$(cat common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
114+ echo "version=$VERSION" >> $GITHUB_OUTPUT
112115
113116 - name : Create nix flake revision tarball
114117 run : |
0 commit comments