119ea8026Sopenharmony_ciname: release 219ea8026Sopenharmony_cion: 319ea8026Sopenharmony_ci workflow_run: 419ea8026Sopenharmony_ci workflows: [test] 519ea8026Sopenharmony_ci branches: [master] 619ea8026Sopenharmony_ci types: [completed] 719ea8026Sopenharmony_ci 819ea8026Sopenharmony_cijobs: 919ea8026Sopenharmony_ci release: 1019ea8026Sopenharmony_ci runs-on: ubuntu-18.04 1119ea8026Sopenharmony_ci 1219ea8026Sopenharmony_ci # need to manually check for a couple things 1319ea8026Sopenharmony_ci # - tests passed? 1419ea8026Sopenharmony_ci # - we are the most recent commit on master? 1519ea8026Sopenharmony_ci if: ${{github.event.workflow_run.conclusion == 'success' && 1619ea8026Sopenharmony_ci github.event.workflow_run.head_sha == github.sha}} 1719ea8026Sopenharmony_ci 1819ea8026Sopenharmony_ci steps: 1919ea8026Sopenharmony_ci - uses: actions/checkout@v2 2019ea8026Sopenharmony_ci with: 2119ea8026Sopenharmony_ci ref: ${{github.event.workflow_run.head_sha}} 2219ea8026Sopenharmony_ci # need workflow access since we push branches 2319ea8026Sopenharmony_ci # containing workflows 2419ea8026Sopenharmony_ci token: ${{secrets.BOT_TOKEN}} 2519ea8026Sopenharmony_ci # need all tags 2619ea8026Sopenharmony_ci fetch-depth: 0 2719ea8026Sopenharmony_ci 2819ea8026Sopenharmony_ci # try to get results from tests 2919ea8026Sopenharmony_ci - uses: dawidd6/action-download-artifact@v2 3019ea8026Sopenharmony_ci continue-on-error: true 3119ea8026Sopenharmony_ci with: 3219ea8026Sopenharmony_ci workflow: ${{github.event.workflow_run.name}} 3319ea8026Sopenharmony_ci run_id: ${{github.event.workflow_run.id}} 3419ea8026Sopenharmony_ci name: results 3519ea8026Sopenharmony_ci path: results 3619ea8026Sopenharmony_ci 3719ea8026Sopenharmony_ci - name: find-version 3819ea8026Sopenharmony_ci run: | 3919ea8026Sopenharmony_ci # rip version from lfs.h 4019ea8026Sopenharmony_ci LFS_VERSION="$(grep -o '^#define LFS_VERSION .*$' lfs.h \ 4119ea8026Sopenharmony_ci | awk '{print $3}')" 4219ea8026Sopenharmony_ci LFS_VERSION_MAJOR="$((0xffff & ($LFS_VERSION >> 16)))" 4319ea8026Sopenharmony_ci LFS_VERSION_MINOR="$((0xffff & ($LFS_VERSION >> 0)))" 4419ea8026Sopenharmony_ci 4519ea8026Sopenharmony_ci # find a new patch version based on what we find in our tags 4619ea8026Sopenharmony_ci LFS_VERSION_PATCH="$( \ 4719ea8026Sopenharmony_ci ( git describe --tags --abbrev=0 \ 4819ea8026Sopenharmony_ci --match="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.*" \ 4919ea8026Sopenharmony_ci || echo 'v0.0.-1' ) \ 5019ea8026Sopenharmony_ci | awk -F '.' '{print $3+1}')" 5119ea8026Sopenharmony_ci 5219ea8026Sopenharmony_ci # found new version 5319ea8026Sopenharmony_ci LFS_VERSION="v$LFS_VERSION_MAJOR` 5419ea8026Sopenharmony_ci `.$LFS_VERSION_MINOR` 5519ea8026Sopenharmony_ci `.$LFS_VERSION_PATCH" 5619ea8026Sopenharmony_ci echo "LFS_VERSION=$LFS_VERSION" 5719ea8026Sopenharmony_ci echo "LFS_VERSION=$LFS_VERSION" >> $GITHUB_ENV 5819ea8026Sopenharmony_ci echo "LFS_VERSION_MAJOR=$LFS_VERSION_MAJOR" >> $GITHUB_ENV 5919ea8026Sopenharmony_ci echo "LFS_VERSION_MINOR=$LFS_VERSION_MINOR" >> $GITHUB_ENV 6019ea8026Sopenharmony_ci echo "LFS_VERSION_PATCH=$LFS_VERSION_PATCH" >> $GITHUB_ENV 6119ea8026Sopenharmony_ci 6219ea8026Sopenharmony_ci # try to find previous version? 6319ea8026Sopenharmony_ci - name: find-prev-version 6419ea8026Sopenharmony_ci continue-on-error: true 6519ea8026Sopenharmony_ci run: | 6619ea8026Sopenharmony_ci LFS_PREV_VERSION="$(git describe --tags --abbrev=0 --match 'v*')" 6719ea8026Sopenharmony_ci echo "LFS_PREV_VERSION=$LFS_PREV_VERSION" 6819ea8026Sopenharmony_ci echo "LFS_PREV_VERSION=$LFS_PREV_VERSION" >> $GITHUB_ENV 6919ea8026Sopenharmony_ci 7019ea8026Sopenharmony_ci # try to find results from tests 7119ea8026Sopenharmony_ci - name: collect-results 7219ea8026Sopenharmony_ci run: | 7319ea8026Sopenharmony_ci # previous results to compare against? 7419ea8026Sopenharmony_ci [ -n "$LFS_PREV_VERSION" ] && curl -sS \ 7519ea8026Sopenharmony_ci "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/` 7619ea8026Sopenharmony_ci `status/$LFS_PREV_VERSION" \ 7719ea8026Sopenharmony_ci | jq -re 'select(.sha != env.GITHUB_SHA) | .statuses[]' \ 7819ea8026Sopenharmony_ci >> prev-results.json \ 7919ea8026Sopenharmony_ci || true 8019ea8026Sopenharmony_ci 8119ea8026Sopenharmony_ci # unfortunately these each have their own format 8219ea8026Sopenharmony_ci [ -e results/code-thumb.csv ] && ( \ 8319ea8026Sopenharmony_ci export PREV="$(jq -re ' 8419ea8026Sopenharmony_ci select(.context == "results / code").description 8519ea8026Sopenharmony_ci | capture("Code size is (?<result>[0-9]+)").result' \ 8619ea8026Sopenharmony_ci prev-results.json || echo 0)" 8719ea8026Sopenharmony_ci ./scripts/code.py -u results/code-thumb.csv -s | awk ' 8819ea8026Sopenharmony_ci NR==2 {printf "Code size,%d B",$2} 8919ea8026Sopenharmony_ci NR==2 && ENVIRON["PREV"]+0 != 0 { 9019ea8026Sopenharmony_ci printf " (%+.1f%%)",100*($2-ENVIRON["PREV"])/ENVIRON["PREV"]} 9119ea8026Sopenharmony_ci NR==2 {printf "\n"}' \ 9219ea8026Sopenharmony_ci >> results.csv) 9319ea8026Sopenharmony_ci [ -e results/code-thumb-readonly.csv ] && ( \ 9419ea8026Sopenharmony_ci export PREV="$(jq -re ' 9519ea8026Sopenharmony_ci select(.context == "results / code (readonly)").description 9619ea8026Sopenharmony_ci | capture("Code size is (?<result>[0-9]+)").result' \ 9719ea8026Sopenharmony_ci prev-results.json || echo 0)" 9819ea8026Sopenharmony_ci ./scripts/code.py -u results/code-thumb-readonly.csv -s | awk ' 9919ea8026Sopenharmony_ci NR==2 {printf "Code size<br/>(readonly),%d B",$2} 10019ea8026Sopenharmony_ci NR==2 && ENVIRON["PREV"]+0 != 0 { 10119ea8026Sopenharmony_ci printf " (%+.1f%%)",100*($2-ENVIRON["PREV"])/ENVIRON["PREV"]} 10219ea8026Sopenharmony_ci NR==2 {printf "\n"}' \ 10319ea8026Sopenharmony_ci >> results.csv) 10419ea8026Sopenharmony_ci [ -e results/code-thumb-threadsafe.csv ] && ( \ 10519ea8026Sopenharmony_ci export PREV="$(jq -re ' 10619ea8026Sopenharmony_ci select(.context == "results / code (threadsafe)").description 10719ea8026Sopenharmony_ci | capture("Code size is (?<result>[0-9]+)").result' \ 10819ea8026Sopenharmony_ci prev-results.json || echo 0)" 10919ea8026Sopenharmony_ci ./scripts/code.py -u results/code-thumb-threadsafe.csv -s | awk ' 11019ea8026Sopenharmony_ci NR==2 {printf "Code size<br/>(threadsafe),%d B",$2} 11119ea8026Sopenharmony_ci NR==2 && ENVIRON["PREV"]+0 != 0 { 11219ea8026Sopenharmony_ci printf " (%+.1f%%)",100*($2-ENVIRON["PREV"])/ENVIRON["PREV"]} 11319ea8026Sopenharmony_ci NR==2 {printf "\n"}' \ 11419ea8026Sopenharmony_ci >> results.csv) 11519ea8026Sopenharmony_ci [ -e results/code-thumb-migrate.csv ] && ( \ 11619ea8026Sopenharmony_ci export PREV="$(jq -re ' 11719ea8026Sopenharmony_ci select(.context == "results / code (migrate)").description 11819ea8026Sopenharmony_ci | capture("Code size is (?<result>[0-9]+)").result' \ 11919ea8026Sopenharmony_ci prev-results.json || echo 0)" 12019ea8026Sopenharmony_ci ./scripts/code.py -u results/code-thumb-migrate.csv -s | awk ' 12119ea8026Sopenharmony_ci NR==2 {printf "Code size<br/>(migrate),%d B",$2} 12219ea8026Sopenharmony_ci NR==2 && ENVIRON["PREV"]+0 != 0 { 12319ea8026Sopenharmony_ci printf " (%+.1f%%)",100*($2-ENVIRON["PREV"])/ENVIRON["PREV"]} 12419ea8026Sopenharmony_ci NR==2 {printf "\n"}' \ 12519ea8026Sopenharmony_ci >> results.csv) 12619ea8026Sopenharmony_ci [ -e results/code-thumb-error-asserts.csv ] && ( \ 12719ea8026Sopenharmony_ci export PREV="$(jq -re ' 12819ea8026Sopenharmony_ci select(.context == "results / code (error-asserts)").description 12919ea8026Sopenharmony_ci | capture("Code size is (?<result>[0-9]+)").result' \ 13019ea8026Sopenharmony_ci prev-results.json || echo 0)" 13119ea8026Sopenharmony_ci ./scripts/code.py -u results/code-thumb-error-asserts.csv -s | awk ' 13219ea8026Sopenharmony_ci NR==2 {printf "Code size<br/>(error-asserts),%d B",$2} 13319ea8026Sopenharmony_ci NR==2 && ENVIRON["PREV"]+0 != 0 { 13419ea8026Sopenharmony_ci printf " (%+.1f%%)",100*($2-ENVIRON["PREV"])/ENVIRON["PREV"]} 13519ea8026Sopenharmony_ci NR==2 {printf "\n"}' \ 13619ea8026Sopenharmony_ci >> results.csv) 13719ea8026Sopenharmony_ci [ -e results/coverage.csv ] && ( \ 13819ea8026Sopenharmony_ci export PREV="$(jq -re ' 13919ea8026Sopenharmony_ci select(.context == "results / coverage").description 14019ea8026Sopenharmony_ci | capture("Coverage is (?<result>[0-9\\.]+)").result' \ 14119ea8026Sopenharmony_ci prev-results.json || echo 0)" 14219ea8026Sopenharmony_ci ./scripts/coverage.py -u results/coverage.csv -s | awk -F '[ /%]+' ' 14319ea8026Sopenharmony_ci NR==2 {printf "Coverage,%.1f%% of %d lines",$4,$3} 14419ea8026Sopenharmony_ci NR==2 && ENVIRON["PREV"]+0 != 0 { 14519ea8026Sopenharmony_ci printf " (%+.1f%%)",$4-ENVIRON["PREV"]} 14619ea8026Sopenharmony_ci NR==2 {printf "\n"}' \ 14719ea8026Sopenharmony_ci >> results.csv) 14819ea8026Sopenharmony_ci 14919ea8026Sopenharmony_ci # transpose to GitHub table 15019ea8026Sopenharmony_ci [ -e results.csv ] || exit 0 15119ea8026Sopenharmony_ci awk -F ',' ' 15219ea8026Sopenharmony_ci {label[NR]=$1; value[NR]=$2} 15319ea8026Sopenharmony_ci END { 15419ea8026Sopenharmony_ci for (r=1; r<=NR; r++) {printf "| %s ",label[r]}; printf "|\n"; 15519ea8026Sopenharmony_ci for (r=1; r<=NR; r++) {printf "|:--"}; printf "|\n"; 15619ea8026Sopenharmony_ci for (r=1; r<=NR; r++) {printf "| %s ",value[r]}; printf "|\n"}' \ 15719ea8026Sopenharmony_ci results.csv > results.txt 15819ea8026Sopenharmony_ci echo "RESULTS:" 15919ea8026Sopenharmony_ci cat results.txt 16019ea8026Sopenharmony_ci 16119ea8026Sopenharmony_ci # find changes from history 16219ea8026Sopenharmony_ci - name: collect-changes 16319ea8026Sopenharmony_ci run: | 16419ea8026Sopenharmony_ci [ -n "$LFS_PREV_VERSION" ] || exit 0 16519ea8026Sopenharmony_ci # use explicit link to github commit so that release notes can 16619ea8026Sopenharmony_ci # be copied elsewhere 16719ea8026Sopenharmony_ci git log "$LFS_PREV_VERSION.." \ 16819ea8026Sopenharmony_ci --grep='^Merge' --invert-grep \ 16919ea8026Sopenharmony_ci --format="format:[\`%h\`](` 17019ea8026Sopenharmony_ci `https://github.com/$GITHUB_REPOSITORY/commit/%h) %s" \ 17119ea8026Sopenharmony_ci > changes.txt 17219ea8026Sopenharmony_ci echo "CHANGES:" 17319ea8026Sopenharmony_ci cat changes.txt 17419ea8026Sopenharmony_ci 17519ea8026Sopenharmony_ci # create and update major branches (vN and vN-prefix) 17619ea8026Sopenharmony_ci - name: create-major-branches 17719ea8026Sopenharmony_ci run: | 17819ea8026Sopenharmony_ci # create major branch 17919ea8026Sopenharmony_ci git branch "v$LFS_VERSION_MAJOR" HEAD 18019ea8026Sopenharmony_ci 18119ea8026Sopenharmony_ci # create major prefix branch 18219ea8026Sopenharmony_ci git config user.name ${{secrets.BOT_USER}} 18319ea8026Sopenharmony_ci git config user.email ${{secrets.BOT_EMAIL}} 18419ea8026Sopenharmony_ci git fetch "https://github.com/$GITHUB_REPOSITORY.git" \ 18519ea8026Sopenharmony_ci "v$LFS_VERSION_MAJOR-prefix" || true 18619ea8026Sopenharmony_ci ./scripts/prefix.py "lfs$LFS_VERSION_MAJOR" 18719ea8026Sopenharmony_ci git branch "v$LFS_VERSION_MAJOR-prefix" $( \ 18819ea8026Sopenharmony_ci git commit-tree $(git write-tree) \ 18919ea8026Sopenharmony_ci $(git rev-parse --verify -q FETCH_HEAD | sed -e 's/^/-p /') \ 19019ea8026Sopenharmony_ci -p HEAD \ 19119ea8026Sopenharmony_ci -m "Generated v$LFS_VERSION_MAJOR prefixes") 19219ea8026Sopenharmony_ci git reset --hard 19319ea8026Sopenharmony_ci 19419ea8026Sopenharmony_ci # push! 19519ea8026Sopenharmony_ci git push --atomic origin \ 19619ea8026Sopenharmony_ci "v$LFS_VERSION_MAJOR" \ 19719ea8026Sopenharmony_ci "v$LFS_VERSION_MAJOR-prefix" 19819ea8026Sopenharmony_ci 19919ea8026Sopenharmony_ci # build release notes 20019ea8026Sopenharmony_ci - name: create-release 20119ea8026Sopenharmony_ci run: | 20219ea8026Sopenharmony_ci # create release and patch version tag (vN.N.N) 20319ea8026Sopenharmony_ci # only draft if not a patch release 20419ea8026Sopenharmony_ci [ -e results.txt ] && export RESULTS="$(cat results.txt)" 20519ea8026Sopenharmony_ci [ -e changes.txt ] && export CHANGES="$(cat changes.txt)" 20619ea8026Sopenharmony_ci curl -sS -X POST -H "authorization: token ${{secrets.BOT_TOKEN}}" \ 20719ea8026Sopenharmony_ci "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases" \ 20819ea8026Sopenharmony_ci -d "$(jq -n '{ 20919ea8026Sopenharmony_ci tag_name: env.LFS_VERSION, 21019ea8026Sopenharmony_ci name: env.LFS_VERSION | rtrimstr(".0"), 21119ea8026Sopenharmony_ci target_commitish: "${{github.event.workflow_run.head_sha}}", 21219ea8026Sopenharmony_ci draft: env.LFS_VERSION | endswith(".0"), 21319ea8026Sopenharmony_ci body: [env.RESULTS, env.CHANGES | select(.)] | join("\n\n")}' \ 21419ea8026Sopenharmony_ci | tee /dev/stderr)" 21519ea8026Sopenharmony_ci 216