-
-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify release flags and correctly mark dev build releases #1324
Changes from 4 commits
7175115
cecbd97
a398b43
3a1b25c
755dab2
9759d92
dade305
60b4992
639e1f1
084bad5
adcef14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -11,17 +11,36 @@ 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 | ||||||||||
|
||||||||||
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 | ||||||||||
needs: calculate-release-flags | ||||||||||
strategy: | ||||||||||
matrix: | ||||||||||
include: | ||||||||||
|
@@ -69,6 +88,7 @@ jobs: | |||||||||
|
||||||||||
release: | ||||||||||
name: Release | ||||||||||
if: ${{ steps.calculate-release-flags.outputs.release-detected == 'true' }} | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, thank you! |
||||||||||
needs: binaries | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wrote that way because the |
||||||||||
runs-on: ubuntu-latest | ||||||||||
steps: | ||||||||||
|
@@ -80,22 +100,10 @@ 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 | ||||||||||
|
||||||||||
- name: Binaries | Checksums | ||||||||||
if: ${{ steps.release.outputs.release-detected == 'true' }} | ||||||||||
run: | | ||||||||||
# Build binary checksums | ||||||||||
for file in "${PROJ_NAME}"-*/"${PROJ_NAME}"-*; do | ||||||||||
|
@@ -105,15 +113,13 @@ 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 }} | ||||||||||
name: ${{ steps.release.outputs.tag-name }} | ||||||||||
files: ${{ env.PROJ_NAME }}-*/${{ env.PROJ_NAME }}-* | ||||||||||
|
||||||||||
- name: Release | Crates.io | ||||||||||
if: ${{ steps.release.outputs.release-detected == 'true' }} | ||||||||||
env: | ||||||||||
RUST_LOG: info | ||||||||||
run: | | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name can be changed, as for me it is a bit misleading. I propose e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The release operator doesn't set any environment variables, it sets github actions outputs. Environment variables, as a best practice, are always written in all caps. So I would propose to call it On the aforementioned step - the one that runs - name: Some step
env:
RELEASE_DETECTED: needs.calculate-release-flags.outputs.release-detected
# ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm open to renaming this output/variable, although I'm not sure about Personally, I'd be fine with |
||
println!("cargo:rerun-if-env-changed=release-detected"); | ||
|
||
let full_string = match (commit, official_release) { | ||
(Some(commit), true) => format!("{pkg_version} ({commit})"), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, this is the way to go.
Minor thing to fix: the job needs to define the output that the release operator populates, see:
https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs
Like that, the subsequent jobs can access the data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed 👍🏻