Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 46 additions & 4 deletions .github/workflows/test-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,48 @@ jobs:
with:
# all history is needed to crawl it properly
fetch-depth: 0
- name: Count run number
id: count
uses: actions/github-script@v9
with:
script: |
const pr = context.payload.pull_request;
if (!pr) {
core.setFailed("This workflow must be triggered by a pull request.");
return;
}

const pr_number = pr.number;
const workflow_name = context.workflow;
const branch_name = pr.head.ref;
const event_match = "pull_request";
console.log("PR Number: " + pr_number);
console.log("Workflow name: " + workflow_name);
console.log("Branch name: " + branch_name);

if (!pr_number) {
console.log("No pull request number found in context.");
core.setOutput("count", 0);
return;
}

const runs = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
event: event_match,
branch: branch_name,
per_page: 100
});

const filtered = runs.data.workflow_runs.filter(run =>
run.name === workflow_name &&
run.event === event_match &&
run.pull_requests?.some(p => p.number === pr_number)
);
console.log("Matches for filters aka runs: " + filtered.length);

const count = filtered.length > 0 ? filtered.length : 1;
core.setOutput("rc_number", count);
- name: Set up Python
uses: actions/setup-python@v6
with:
Expand Down Expand Up @@ -54,7 +96,7 @@ jobs:
--changelog_file changelog.md \
--version_file be_upy_blink/version.py \
--version_file_type py \
--additional_version_info="-rc${{ github.run_number }}.dev${{ github.event.number }}" \
--additional_version_info="-rc${{ steps.count.outputs.rc_number }}.dev${{ github.event.number }}" \
--debug
- name: Build package
run: |
Expand All @@ -70,7 +112,7 @@ jobs:
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
# ${{ github.repository }} and ${{ github.ref_name }} can't be used
# for artifact name due to unallowed '/'
name: dist_repo.${{ github.event.repository.name }}_sha.${{ github.sha }}_build.${{ github.run_number }}
name: dist_repo.${{ github.event.repository.name }}_sha.${{ github.sha }}_build.${{ steps.count.outputs.rc_number }}
path: dist/*.tar.gz
retention-days: 14
- name: Publish package
Expand All @@ -89,8 +131,8 @@ jobs:
# or you set the "contents" permissions to "write" as in this example
changelog-path: changelog.md
tag-name-prefix: ''
tag-name-extension: '-rc${{ github.run_number }}.dev${{ github.event.number }}'
tag-name-extension: '-rc${{ steps.count.outputs.rc_number }}.dev${{ github.event.number }}'
release-name-prefix: ''
release-name-extension: '-rc${{ github.run_number }}.dev${{ github.event.number }}'
release-name-extension: '-rc${{ steps.count.outputs.rc_number }}.dev${{ github.event.number }}'
draft-release: true
prerelease: true
10 changes: 10 additions & 0 deletions .snippets/33.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Set correct release candidate number
<!--
type: bugfix
scope: all
affected: all
-->

This change creates the correct release candidate number based on the action run of a pull request workflow run `test-release` instead of the total number of this workflow run. By this fix, the `-rcX` metadata starts at `1` and is incremented with every push, no matter if the push is a force push or a classic new commit on top in a ongoing pull request.

This closes [#33](https://github.com/brainelectronics/micropython-package-template/issues/33)
2 changes: 1 addition & 1 deletion be_upy_blink/version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

__version_info__ = ("0", "13", "0")
__version_info__ = ("0", "13", "1")
__version__ = '.'.join(__version_info__)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
]
],
"deps": [],
"version": "0.13.0"
"version": "0.13.1"
}
Loading