31
31
id : set_version
32
32
run : echo "version=$(git cliff --bumped-version)" >> "$GITHUB_OUTPUT"
33
33
34
- build_and_test :
35
- name : Build & Test for ${{ matrix.config.target }}
36
- needs : extract_version
37
- strategy :
38
- matrix :
39
- config :
40
- - { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu }
41
- - { os: ubuntu-22.04, target: aarch64-unknown-linux-gnu }
42
- - { os: macos-14, target: x86_64-apple-darwin }
43
- - { os: macos-14, target: aarch64-apple-darwin }
44
- - { os: windows-2022, target: x86_64-pc-windows-msvc }
45
- - { os: windows-2022, target: aarch64-pc-windows-msvc }
46
-
47
- runs-on : ${{ matrix.config.os }}
48
-
49
- outputs :
50
- artifact_url : ${{ steps.upload-artifacts.outputs.artifact-url }}
51
-
52
- steps :
53
- - uses : actions/checkout@v4
54
- with :
55
- submodules : true
56
- - uses : actions-rust-lang/setup-rust-toolchain@v1
57
- with :
58
- target : ${{ matrix.config.target }}
59
-
60
- - uses : Swatinem/rust-cache@v2
61
- id : rust-cache
62
-
63
- # The Aarch64 Linux is a special snowflake, we need to install its toolchain
64
- - name : Install arm64 toolchain
65
- if : matrix.config.target == 'aarch64-unknown-linux-gnu'
66
- run : |
67
- sudo apt-get update
68
- sudo apt-get install -y gcc-aarch64-linux-gnu
69
-
70
- # running containers via `services` only works on linux
71
- # https://github.com/actions/runner/issues/1866
72
- - name : 🐘 Setup postgres
73
- uses : ikalnytskyi/action-setup-postgres@v7
74
-
75
- - name : 🧪 Run Tests
76
- run : cargo test --release
77
- env :
78
- DATABASE_URL : postgres://postgres:postgres@localhost:5432/postgres
79
-
80
- - name : 🛠️ Run Build
81
- run : cargo build -p pgt_cli --release --target ${{ matrix.config.target }}
82
- env :
83
- # Strip all debug symbols from the resulting binaries
84
- RUSTFLAGS : " -C strip=symbols -C codegen-units=1"
85
- # Inline the version in the CLI binary
86
- PGT_VERSION : ${{ needs.extract_version.outputs.version }}
87
-
88
- # windows is a special snowflake too, it saves binaries as .exe
89
- - name : 👦 Name the Binary
90
- if : matrix.config.os == 'windows-2022'
91
- run : |
92
- mkdir dist
93
- cp target/${{ matrix.config.target }}/release/postgrestools.exe ./dist/postgrestools_${{ matrix.config.target }}
94
- - name : 👦 Name the Binary
95
- if : matrix.config.os != 'windows-2022'
96
- run : |
97
- mkdir dist
98
- cp target/${{ matrix.config.target }}/release/postgrestools ./dist/postgrestools_${{ matrix.config.target }}
99
-
100
- # It is not possible to return the artifacts from the matrix jobs individually: Matrix outputs overwrite each other.
101
- # A common workaround is to upload and download the resulting artifacts.
102
- - name : 👆 Upload Artifacts
103
- id : upload-artifacts
104
- uses : actions/upload-artifact@v4
105
- with :
106
- name : postgrestools_${{ matrix.config.target }}
107
- path : ./dist/postgrestools_*
108
- # The default compression level is 6; this took the binary down from 350 to 330MB.
109
- # It is recommended to use a lower level for binaries, since the compressed result is not much smaller,
110
- # and the higher levels of compression take much longer.
111
- compression-level : 2
112
- if-no-files-found : error
113
-
114
34
create_changelog_and_release :
115
35
runs-on : ubuntu-latest
116
- needs : [extract_version, build_and_test ] # make sure that tests & build work correctly
36
+ needs : [extract_version] # make sure that tests & build work correctly
117
37
steps :
118
38
- name : Checkout Repo
119
39
uses : actions/checkout@v4
@@ -130,17 +50,6 @@ jobs:
130
50
env :
131
51
GITHUB_REPO : ${{ github.repository }}
132
52
133
- - name : Ensure tag matches
134
- if : steps.create_changelog.outputs.version != needs.extract_version.outputs.version
135
- run : exit 1
136
-
137
- - name : 👇 Download Artifacts
138
- uses : actions/download-artifact@v4
139
- id : download
140
- with :
141
- merge-multiple : true
142
- pattern : postgrestools_*
143
-
144
53
- name : 📂 Create Release
145
54
uses : softprops/action-gh-release@v2
146
55
id : create-release
0 commit comments