Skip to content

Commit 3454b62

Browse files
committed
chore: resolve versions from ansible/vars.yml instead of packer file
create a matrix build for 15 16 (or how ever many versions there are)
1 parent 7f7730e commit 3454b62

File tree

2 files changed

+60
-17
lines changed

2 files changed

+60
-17
lines changed

.github/workflows/publish-nix-pgupgrade-bin-flake-version.yml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,28 @@ permissions:
1111
id-token: write
1212

1313
jobs:
14+
prepare:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
postgres_versions: ${{ steps.set-versions.outputs.postgres_versions }}
18+
steps:
19+
- name: Checkout Repo
20+
uses: actions/checkout@v3
21+
22+
- uses: DeterminateSystems/nix-installer-action@main
23+
24+
- name: Set PostgreSQL versions
25+
id: set-versions
26+
run: |
27+
VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[]' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c 'split("\n")[:-1]')
28+
echo "postgres_versions=$VERSIONS" >> $GITHUB_OUTPUT
29+
1430
publish-staging:
31+
needs: prepare
1532
runs-on: ubuntu-latest
33+
strategy:
34+
matrix:
35+
postgres_version: ${{ fromJson(needs.prepare.outputs.postgres_versions) }}
1636

1737
steps:
1838
- name: Checkout Repo
@@ -21,10 +41,8 @@ jobs:
2141
- name: Grab release version
2242
id: process_release_version
2343
run: |
24-
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
25-
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
26-
VERSION=${{ inputs.postgresVersion }}
27-
fi
44+
VERSION=$(sudo nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
45+
VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes
2846
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
2947
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT"
3048
@@ -58,6 +76,10 @@ jobs:
5876
publish-prod:
5977
runs-on: ubuntu-latest
6078
if: github.ref_name == 'develop' || contains( github.ref, 'release' )
79+
needs: prepare
80+
strategy:
81+
matrix:
82+
postgres_version: ${{ fromJson(needs.prepare.outputs.postgres_versions) }}
6183

6284
steps:
6385
- name: Checkout Repo
@@ -66,10 +88,8 @@ jobs:
6688
- name: Grab release version
6789
id: process_release_version
6890
run: |
69-
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
70-
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
71-
VERSION=${{ inputs.postgresVersion }}
72-
fi
91+
VERSION=$(sudo nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
92+
VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes
7393
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
7494
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT"
7595

.github/workflows/publish-nix-pgupgrade-scripts.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
- release/*
88
paths:
99
- '.github/workflows/publish-nix-pgupgrade-scripts.yml'
10-
- 'common-nix.vars.pkr.hcl'
1110
workflow_dispatch:
1211
inputs:
1312
postgresVersion:
@@ -18,20 +17,40 @@ permissions:
1817
id-token: write
1918

2019
jobs:
20+
prepare:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
postgres_versions: ${{ steps.set-versions.outputs.postgres_versions }}
24+
steps:
25+
- name: Checkout Repo
26+
uses: actions/checkout@v3
27+
28+
- uses: DeterminateSystems/nix-installer-action@main
29+
30+
- name: Set PostgreSQL versions
31+
id: set-versions
32+
run: |
33+
VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[]' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c 'split("\n")[:-1]')
34+
echo "postgres_versions=$VERSIONS" >> $GITHUB_OUTPUT
35+
2136
publish-staging:
37+
needs: prepare
2238
runs-on: ubuntu-latest
39+
strategy:
40+
matrix:
41+
postgres_version: ${{ fromJson(needs.prepare.outputs.postgres_versions) }}
2342

2443
steps:
2544
- name: Checkout Repo
2645
uses: actions/checkout@v3
2746

47+
- uses: DeterminateSystems/nix-installer-action@main
48+
2849
- name: Grab release version
2950
id: process_release_version
3051
run: |
31-
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
32-
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
33-
VERSION=${{ inputs.postgresVersion }}
34-
fi
52+
VERSION=$(sudo nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
53+
VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes
3554
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
3655
3756
- name: Create a tarball containing pg_upgrade scripts
@@ -61,20 +80,24 @@ jobs:
6180
SLACK_FOOTER: ''
6281

6382
publish-prod:
83+
needs: prepare
6484
runs-on: ubuntu-latest
6585
if: github.ref_name == 'develop' || contains( github.ref, 'release' )
6686

87+
strategy:
88+
matrix:
89+
postgres_version: ${{ fromJson(needs.prepare.outputs.postgres_versions) }}
90+
91+
6792
steps:
6893
- name: Checkout Repo
6994
uses: actions/checkout@v3
7095

7196
- name: Grab release version
7297
id: process_release_version
7398
run: |
74-
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
75-
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
76-
VERSION=${{ inputs.postgresVersion }}
77-
fi
99+
VERSION=$(sudo nix run nixpkgs#yq -- '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml)
100+
VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes
78101
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
79102
80103
- name: Create a tarball containing pg_upgrade scripts

0 commit comments

Comments
 (0)