Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Haster <chaster@utexas.edu>2021-01-04 06:14:49 +0300
committerChristopher Haster <chaster@utexas.edu>2021-01-10 13:03:13 +0300
commit6d3e4ac33e20a4c7394508434840b79e43397701 (patch)
tree736ff19440acff493b693f66b70bf7696df11320 /.github/workflows/release.yml
parent9d6546071b4703d2a0953a887c15aa8b501a834d (diff)
Brought over the release workflow
This is pretty much a cleaned up version of the release script that ran on Travis. This biggest change is that now the release script also collecs the build results into a table as part of the change notes, which is a nice addition.
Diffstat (limited to '.github/workflows/release.yml')
-rw-r--r--.github/workflows/release.yml163
1 files changed, 163 insertions, 0 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..0560eca
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,163 @@
+name: release
+on:
+ workflow_run:
+ workflows: [test]
+ branches: [master]
+ types: [completed]
+
+jobs:
+ release:
+ runs-on: ubuntu-latest
+
+ # need to manually check for a couple things
+ # - tests passed?
+ # - we are the most recent commit on master?
+ if: |
+ github.event.workflow_run.conclusion == 'success' &&
+ github.event.workflow_run.head_sha == github.sha
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ ref: ${{github.event.workflow_run.head_sha}}
+ # need workflow access since we push branches
+ # containing workflows
+ token: ${{secrets.BOT_TOKEN}}
+ # need all tags
+ fetch-depth: 0
+
+ # try to get results from tests
+ - uses: dawidd6/action-download-artifact@v2
+ continue-on-error: true
+ with:
+ workflow: ${{github.event.workflow_run.name}}
+ run_id: ${{github.event.workflow_run.id}}
+ name: results
+ path: results
+
+ - name: find-version
+ run: |
+ # rip version from lfs.h
+ LFS_VERSION="$(grep -o '^#define LFS_VERSION .*$' lfs.h \
+ | awk '{print $3}')"
+ LFS_VERSION_MAJOR="$((0xffff & ($LFS_VERSION >> 16)))"
+ LFS_VERSION_MINOR="$((0xffff & ($LFS_VERSION >> 0)))"
+
+ # find a new patch version based on what we find in our tags
+ LFS_VERSION_PATCH="$( \
+ ( git describe --tags --abbrev=0 \
+ --match="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.*" \
+ || echo 'v0.0.-1' ) \
+ | awk -F '.' '{print $3+1}')"
+
+ # found new version
+ LFS_VERSION="v$LFS_VERSION_MAJOR`
+ `.$LFS_VERSION_MINOR`
+ `.$LFS_VERSION_PATCH"
+ echo "LFS_VERSION=$LFS_VERSION"
+ echo "LFS_VERSION=$LFS_VERSION" >> $GITHUB_ENV
+ echo "LFS_VERSION_MAJOR=$LFS_VERSION_MAJOR" >> $GITHUB_ENV
+ echo "LFS_VERSION_MINOR=$LFS_VERSION_MINOR" >> $GITHUB_ENV
+ echo "LFS_VERSION_PATCH=$LFS_VERSION_PATCH" >> $GITHUB_ENV
+
+ # try to find previous version?
+ - name: find-prev-version
+ continue-on-error: true
+ run: |
+ LFS_PREV_VERSION="$(git describe --tags --abbrev=0 --match 'v*')"
+ echo "LFS_PREV_VERSION=$LFS_PREV_VERSION"
+ echo "LFS_PREV_VERSION=$LFS_PREV_VERSION" >> $GITHUB_ENV
+
+ # try to find results from tests
+ - name: collect-results
+ run: |
+ [ -e results/code-thumb.csv ] && \
+ ./scripts/code.py -u results/code-thumb.csv -s \
+ | awk 'NR==2 {printf "Code size,%d B\n",$2}' \
+ >> results.csv
+ [ -e results/code-thumb-readonly.csv ] && \
+ ./scripts/code.py -u results/code-thumb-readonly.csv -s \
+ | awk 'NR==2 {printf "Code size (readonly),%d B\n",$2}' \
+ >> results.csv
+ [ -e results/code-thumb-threadsafe.csv ] && \
+ ./scripts/code.py -u results/code-thumb-threadsafe.csv -s \
+ | awk 'NR==2 {printf "Code size (threadsafe),%d B\n",$2}' \
+ >> results.csv
+ [ -e results/code-thumb-migrate.csv ] && \
+ ./scripts/code.py -u results/code-thumb-migrate.csv -s \
+ | awk 'NR==2 {printf "Code size (migrate),%d B\n",$2}' \
+ >> results.csv
+ [ -e results/coverage.csv ] && \
+ ./scripts/coverage.py -u results/coverage.csv -s \
+ | awk 'NR==2 {printf "Coverage,%.1f%% of %d lines\n",$4,$3}' \
+ >> results.csv
+
+ [ -e results.csv ] || exit 0
+ awk -F ',' '
+ {label[NR]=$1; value[NR]=$2}
+ END {
+ for (r=1; r<=NR; r++) {printf "| %s ",label[r]}; printf "|\n";
+ for (r=1; r<=NR; r++) {printf "|--:"}; printf "|\n";
+ for (r=1; r<=NR; r++) {printf "| %s ",value[r]}; printf "|\n"}' \
+ results.csv > results.txt
+ echo "RESULTS:"
+ cat results.txt
+
+ # find changes from history
+ - name: collect-changes
+ run: |
+ [ ! -z "$LFS_PREV_VERSION" ] || exit 0
+ git log --oneline "$LFS_PREV_VERSION.." \
+ --grep='^Merge' --invert-grep > changes.txt
+ echo "CHANGES:"
+ cat changes.txt
+
+ # create and update major branches (vN and vN-prefix)
+ - name: build-major-branches
+ run: |
+ # create major branch
+ git branch "v$LFS_VERSION_MAJOR" HEAD
+
+ # create major prefix branch
+ git config user.name ${{secrets.BOT_USERNAME}}
+ git config user.email ${{secrets.BOT_EMAIL}}
+ git fetch "https://github.com/$GITHUB_REPOSITORY.git" \
+ "v$LFS_VERSION_MAJOR-prefix" || true
+ ./scripts/prefix.py "lfs$LFS_VERSION_MAJOR"
+ git branch "v$LFS_VERSION_MAJOR-prefix" $( \
+ git commit-tree $(git write-tree) \
+ $(git rev-parse --verify -q FETCH_HEAD | sed -e 's/^/-p /') \
+ -p HEAD \
+ -m "Generated v$LFS_VERSION_MAJOR prefixes")
+ git reset --hard
+
+ # push!
+ git push --atomic origin \
+ "v$LFS_VERSION_MAJOR" \
+ "v$LFS_VERSION_MAJOR-prefix"
+
+ # build release notes
+ - name: build-release
+ run: |
+ # find changes since last release
+ #if [ ! -z "$LFS_PREV_VERSION" ]
+ #then
+ # export CHANGES="$(git log --oneline "$LFS_PREV_VERSION.." \
+ # --grep='^Merge' --invert-grep)"
+ # printf "CHANGES\n%s\n\n" "$CHANGES"
+ #fi
+
+ # create release and patch version tag (vN.N.N)
+ # only draft if not a patch release
+ [ -e results.txt ] && export RESULTS="$(cat results.txt)"
+ [ -e changes.txt ] && export CHANGES="$(cat changes.txt)"
+ curl -sS -H "authorization: token ${{secrets.BOT_TOKEN}}" \
+ "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases" \
+ -d "$(jq -sR '{
+ tag_name: env.LFS_VERSION,
+ name: env.LFS_VERSION | rtrimstr(".0"),
+ target_commitish: "${{github.event.workflow_run.head_sha}}",
+ draft: env.LFS_VERSION | endswith(".0"),
+ body: [env.RESULTS, env.CHANGES | select(.)] | join("\n\n")}' \
+ | tee /dev/stderr)" > /dev/null
+