From 7175115742dcf9f4c7a0af11a2369b2d59e68b78 Mon Sep 17 00:00:00 2001 From: kopackiw <26244440+kopackiw@users.noreply.github.com> Date: Tue, 8 Nov 2022 02:05:16 +0100 Subject: [PATCH 01/10] Move release operator into separate job --- .github/workflows/cd.yml | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f3e06f461..1866a5272 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -20,6 +20,28 @@ defaults: shell: bash jobs: + calculate-release-flags: + name: Calculate release flags + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Operator | Cache + uses: Swatinem/rust-cache@v2 + with: + key: release-operator-01 + + - name: Operator | Deduce + id: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RELEASE_LABEL: release + RUST_LOG: info + run: | + # Run release operator + cargo run -p release-operator -- detect + binaries: name: Binaries strategy: @@ -80,16 +102,6 @@ jobs: with: key: release-operator-01 - - name: Operator | Deduce - id: release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_LABEL: release - RUST_LOG: info - run: | - # Run release operator - cargo run -p release-operator -- detect - - name: Binaries | Download if: ${{ steps.release.outputs.release-detected == 'true' }} uses: actions/download-artifact@v3 From cecbd97660c5fbbac5e69677585c1755533ab186 Mon Sep 17 00:00:00 2001 From: kopackiw <26244440+kopackiw@users.noreply.github.com> Date: Tue, 8 Nov 2022 02:07:01 +0100 Subject: [PATCH 02/10] Move "if" checks into job rather than separate steps --- .github/workflows/cd.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 1866a5272..0dae741c4 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -91,6 +91,7 @@ jobs: release: name: Release + if: ${{ steps.calculate-release-flags.outputs.release-detected == 'true' }} needs: binaries runs-on: ubuntu-latest steps: @@ -103,11 +104,9 @@ jobs: key: release-operator-01 - name: Binaries | Download - if: ${{ steps.release.outputs.release-detected == 'true' }} uses: actions/download-artifact@v3 - name: Binaries | Checksums - if: ${{ steps.release.outputs.release-detected == 'true' }} run: | # Build binary checksums for file in "${PROJ_NAME}"-*/"${PROJ_NAME}"-*; do @@ -117,7 +116,6 @@ jobs: done - name: Release | GitHub - if: ${{ steps.release.outputs.release-detected == 'true' }} uses: softprops/action-gh-release@v1 with: tag_name: ${{ steps.release.outputs.tag-name }} @@ -125,7 +123,6 @@ jobs: files: ${{ env.PROJ_NAME }}-*/${{ env.PROJ_NAME }}-* - name: Release | Crates.io - if: ${{ steps.release.outputs.release-detected == 'true' }} env: RUST_LOG: info run: | From a398b43753527f797332ec8edb6a03c5e9e121a5 Mon Sep 17 00:00:00 2001 From: kopackiw <26244440+kopackiw@users.noreply.github.com> Date: Tue, 8 Nov 2022 02:09:10 +0100 Subject: [PATCH 03/10] Replace the "FJ_OFFICIAL_RELEASE" flag with the "release-detected" --- .github/workflows/cd.yml | 4 ---- crates/fj/build.rs | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 0dae741c4..44f4dcc18 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -11,10 +11,6 @@ env: # used to rename and upload the binaries PROJ_NAME: fj-app - # This lets our app know it's an "official" release. Otherwise we would get - # a version number like "fj-app 0.8.0 (8cb928bb, unreleased)" - FJ_OFFICIAL_RELEASE: 1 - defaults: run: shell: bash diff --git a/crates/fj/build.rs b/crates/fj/build.rs index da5c3137e..2c879dbd4 100644 --- a/crates/fj/build.rs +++ b/crates/fj/build.rs @@ -23,8 +23,8 @@ impl Version { let commit = git_description(); let official_release = - std::env::var("FJ_OFFICIAL_RELEASE").as_deref() == Ok("1"); - println!("cargo:rerun-if-env-changed=FJ_OFFICIAL_RELEASE"); + std::env::var("release-detected").as_deref() == Ok("true"); + println!("cargo:rerun-if-env-changed=release-detected"); let full_string = match (commit, official_release) { (Some(commit), true) => format!("{pkg_version} ({commit})"), From 3a1b25cd79863161c35f2340f8cc4f5ec549f811 Mon Sep 17 00:00:00 2001 From: kopackiw <26244440+kopackiw@users.noreply.github.com> Date: Tue, 8 Nov 2022 02:10:07 +0100 Subject: [PATCH 04/10] Compiling binaries step now requires calculated release flag step --- .github/workflows/cd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 44f4dcc18..6a96cf8ca 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -40,6 +40,7 @@ jobs: binaries: name: Binaries + needs: calculate-release-flags strategy: matrix: include: From 9759d926eab2da9fe69fd5f70644c5e63b448a0e Mon Sep 17 00:00:00 2001 From: kopackiw <26244440+kopackiw@users.noreply.github.com> Date: Tue, 8 Nov 2022 15:15:53 +0100 Subject: [PATCH 05/10] Set outputs for the `calculate-release-flags` job --- .github/workflows/cd.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 6a96cf8ca..b27d92ec3 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -19,6 +19,9 @@ jobs: calculate-release-flags: name: Calculate release flags runs-on: ubuntu-latest + outputs: + release-detected: ${{ steps.step1.outputs.release-detected }} + steps: - name: Checkout uses: actions/checkout@v3 From dade3052cf0ac6e1d844507e159fc8d045e5b1de Mon Sep 17 00:00:00 2001 From: kopackiw <26244440+kopackiw@users.noreply.github.com> Date: Tue, 8 Nov 2022 15:18:53 +0100 Subject: [PATCH 06/10] Change "steps" to "needs" in the `release` if expression --- .github/workflows/cd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b27d92ec3..aaeadb6d2 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -52,7 +52,7 @@ jobs: - { target: aarch64-apple-darwin, os: macOS-latest } - { target: x86_64-pc-windows-msvc, os: windows-latest } - runs-on: ${{matrix.os}} + runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v3 @@ -91,7 +91,7 @@ jobs: release: name: Release - if: ${{ steps.calculate-release-flags.outputs.release-detected == 'true' }} + if: ${{ needs.calculate-release-flags.outputs.release-detected == 'true' }} needs: binaries runs-on: ubuntu-latest steps: From 60b4992cc630f054e5bbac89f84414d570dd7596 Mon Sep 17 00:00:00 2001 From: kopackiw <26244440+kopackiw@users.noreply.github.com> Date: Tue, 8 Nov 2022 15:19:34 +0100 Subject: [PATCH 07/10] Add `calculate-release-flags` as dependecy for `release` --- .github/workflows/cd.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index aaeadb6d2..7ea8c8e1e 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -92,7 +92,9 @@ jobs: release: name: Release if: ${{ needs.calculate-release-flags.outputs.release-detected == 'true' }} - needs: binaries + needs: + - calculate-release-flags + - binaries runs-on: ubuntu-latest steps: - name: Checkout From 639e1f1ba4a6afa5916490d633ed0e74a49a7403 Mon Sep 17 00:00:00 2001 From: kopackiw <26244440+kopackiw@users.noreply.github.com> Date: Tue, 8 Nov 2022 15:32:57 +0100 Subject: [PATCH 08/10] Pass `RELEASE_DETECTED` as env for a compilation step --- .github/workflows/cd.yml | 2 ++ crates/fj/build.rs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 7ea8c8e1e..e85e07662 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -67,6 +67,8 @@ jobs: - name: Binaries | Compile run: cargo build --release --target ${{ matrix.target }} + env: + RELEASE_DETECTED: ${{ needs.calculate-release-flags.outputs.release-detected }} - name: Binaries | Prepare upload run: | diff --git a/crates/fj/build.rs b/crates/fj/build.rs index 2c879dbd4..ec12d4477 100644 --- a/crates/fj/build.rs +++ b/crates/fj/build.rs @@ -23,8 +23,8 @@ impl Version { let commit = git_description(); let official_release = - std::env::var("release-detected").as_deref() == Ok("true"); - println!("cargo:rerun-if-env-changed=release-detected"); + std::env::var("RELEASE_DETECTED").as_deref() == Ok("true"); + println!("cargo:rerun-if-env-changed=RELEASE_DETECTED"); let full_string = match (commit, official_release) { (Some(commit), true) => format!("{pkg_version} ({commit})"), From 084bad5927ce850eea9ecb6f10aaca6fc00924ac Mon Sep 17 00:00:00 2001 From: kopackiw <26244440+kopackiw@users.noreply.github.com> Date: Tue, 8 Nov 2022 15:37:08 +0100 Subject: [PATCH 09/10] Fix step name --- .github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index e85e07662..253783b96 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -20,7 +20,7 @@ jobs: name: Calculate release flags runs-on: ubuntu-latest outputs: - release-detected: ${{ steps.step1.outputs.release-detected }} + release-detected: ${{ steps.release.outputs.release-detected }} steps: - name: Checkout From adcef143f1e349af84f61f28f7fe055fd3721bbf Mon Sep 17 00:00:00 2001 From: kopackiw <26244440+kopackiw@users.noreply.github.com> Date: Tue, 8 Nov 2022 15:39:03 +0100 Subject: [PATCH 10/10] Bring back removed comment for clarity with new env --- .github/workflows/cd.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 253783b96..80457c6cc 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -68,6 +68,8 @@ jobs: - name: Binaries | Compile run: cargo build --release --target ${{ matrix.target }} env: + # This lets our app know it's an "official" release. Otherwise we would get + # a version number like "fj-app 0.8.0 (8cb928bb, unreleased)" RELEASE_DETECTED: ${{ needs.calculate-release-flags.outputs.release-detected }} - name: Binaries | Prepare upload