mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-25 07:07:57 +00:00
ci: update release flow and publish list.json (#276)
This pull request adds changes described in **this comment**: - `.github/scripts/json_generator.py` - a small script that generates several json files for different platforms. - [generate_versions.yml](https://github.com/paritytech/revive/compare/as-release-json?expand=1#diff-2aee05b96020ac60943e6dfcb30597e53898f31542aeb570468b970d9a13a5a6) - the workflow that runs when release is published, creates info.json files and pushes them into resolc-bin repo - `js/build.js` is adjusted in order to set `RESOLC_WASM_URI` from env variable - ⚠️ Release workflow is changed: - In PRs and main branch it'll only build artifacts - Release will happen automatically only on the `v*` tag push. This is needed for revive_web.js to have the necessary `RESOLC_WASM_URI` - workflow will check that version in Cargo.toml is the same as the tag when the new tag is pushed cc https://github.com/paritytech/revive/issues/162 cc https://github.com/paritytech/devops/issues/3890
This commit is contained in:
committed by
GitHub
parent
7d8fa75a0f
commit
0dafc779ce
@@ -0,0 +1,64 @@
|
||||
name: Generate JSON for resolc-bin
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
generateJson:
|
||||
runs-on: ubuntu-latest
|
||||
if: contains(github.event.release.tag_name, 'llvm') == false
|
||||
environment: tags
|
||||
env:
|
||||
# the token is needed for json_generator.py
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: tmp
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: paritytech/resolc-bin
|
||||
path: resolc-bin
|
||||
|
||||
- uses: actions/create-github-app-token@v1
|
||||
id: app-token
|
||||
with:
|
||||
app-id: ${{ secrets.REVIVE_JSON_APP_ID }}
|
||||
private-key: ${{ secrets.REVIVE_JSON_APP_KEY }}
|
||||
owner: paritytech
|
||||
repositories: resolc-bin
|
||||
|
||||
- name: Generate json and push
|
||||
env:
|
||||
TOKEN: ${{ steps.app-token.outputs.token }}
|
||||
APP_NAME: "paritytech-revive-json"
|
||||
Green: "\e[32m"
|
||||
NC: "\e[0m"
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install -y wget
|
||||
wget https://github.com/${GITHUB_REPOSITORY}/releases/download/${GITHUB_REF_NAME}/resolc-x86_64-unknown-linux-musl
|
||||
chmod +x resolc-x86_64-unknown-linux-musl
|
||||
export FIRST_SOLC_VERSION=$(./resolc-x86_64-unknown-linux-musl --supported-solc-versions | cut -f 1 -d "," | tr -d ">=")
|
||||
export LAST_SOLC_VERSION=$(./resolc-x86_64-unknown-linux-musl --supported-solc-versions | cut -f 2 -d "," | tr -d "<=")
|
||||
|
||||
cd resolc-bin
|
||||
python ../tmp/.github/scripts/json_generator.py ${GITHUB_REPOSITORY} ${{ github.event.release.tag_name }}
|
||||
|
||||
echo "${Green}Add new remote with gh app token${NC}"
|
||||
git remote set-url origin $(git config remote.origin.url | sed "s/github.com/${APP_NAME}:${TOKEN}@github.com/g")
|
||||
|
||||
echo "${Green}Remove http section that causes issues with gh app auth token${NC}"
|
||||
sed -i.bak '/\[http/d' ./.git/config
|
||||
sed -i.bak '/extraheader/d' ./.git/config
|
||||
|
||||
git config user.email "ci@parity.io"
|
||||
git config user.name "${APP_NAME}"
|
||||
|
||||
git add .
|
||||
git commit -m "Update json"
|
||||
git push origin main
|
||||
|
||||
echo "::notice::info.list files were successfully published to https://github.com/paritytech/resolc-bin"
|
||||
@@ -1,11 +1,12 @@
|
||||
name: Release
|
||||
name: Build & Release
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
tags:
|
||||
- "v*"
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
types: [opened, synchronize, labeled, unlabeled]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
@@ -17,41 +18,44 @@ env:
|
||||
|
||||
jobs:
|
||||
check-version-changed:
|
||||
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'release-test')
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: write
|
||||
env:
|
||||
CURRENT_TAG: ${{ github.ref_name }}
|
||||
outputs:
|
||||
TAG: ${{ steps.versions.outputs.TAG }}
|
||||
PKG_VER: ${{ steps.versions.outputs.PKG_VER }}
|
||||
RELEASE_NOTES: ${{ steps.versions.outputs.RELEASE_NOTES }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-tags: true
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check Versions
|
||||
# Check that tag and version in Cargo.toml match
|
||||
- name: Check versions
|
||||
id: versions
|
||||
run: |
|
||||
export CURRENT_TAG=$(git describe --tags --abbrev=0 --exclude "llvm-*")
|
||||
if [[ $CURRENT_TAG == 'main' ]];
|
||||
then
|
||||
echo "::notice::Tag $CURRENT_TAG is not a release tag, skipping the check in the main branch";
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $CURRENT_TAG != "v"* ]];
|
||||
then
|
||||
echo "::notice::Tag $CURRENT_TAG is not a release tag, skipping the check in a PR";
|
||||
exit 0
|
||||
fi
|
||||
|
||||
export PKG_VER=v$(cat Cargo.toml | grep -A 5 package] | grep version | cut -d '=' -f 2 | tr -d '"' | tr -d " ")
|
||||
echo "Current tag $CURRENT_TAG"
|
||||
echo "Package version $PKG_VER"
|
||||
#
|
||||
echo "PKG_VER=$PKG_VER" >> $GITHUB_OUTPUT
|
||||
if [[ $CURRENT_TAG == $PKG_VER ]];
|
||||
if [[ $CURRENT_TAG != $PKG_VER ]];
|
||||
then
|
||||
echo "Tag is up to date. Nothing to do.";
|
||||
export TAG=old;
|
||||
else
|
||||
echo "Tag was updated.";
|
||||
export TAG=new;
|
||||
echo "::error::Tag $CURRENT_TAG doesn't match package version $PKG_VER in Cargo.toml, please fix";
|
||||
exit 1
|
||||
fi
|
||||
echo "TAG=$TAG" >> $GITHUB_OUTPUT
|
||||
|
||||
# Generating release notes early, in order to avoid checkout at the last step
|
||||
export RELEASE_NOTES="$(sed '/^## '${PKG_VER}'/,/^## v/!d' CHANGELOG.md | sed -e '1d' -e '$d')"
|
||||
export RELEASE_NOTES="$(sed '/^## '${CURRENT_TAG}'/,/^## v/!d' CHANGELOG.md | sed -e '1d' -e '$d')"
|
||||
|
||||
echo "Release notes:"
|
||||
echo "$RELEASE_NOTES"
|
||||
@@ -83,7 +87,6 @@ jobs:
|
||||
- target: x86_64-pc-windows-msvc
|
||||
type: native
|
||||
runner: windows-2022
|
||||
if: ${{ needs.check-version-changed.outputs.TAG == 'new' }}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
needs: [check-version-changed]
|
||||
steps:
|
||||
@@ -137,9 +140,10 @@ jobs:
|
||||
retention-days: 1
|
||||
|
||||
build-wasm:
|
||||
if: ${{ needs.check-version-changed.outputs.TAG == 'new' }}
|
||||
runs-on: ubuntu-24.04
|
||||
needs: [check-version-changed]
|
||||
env:
|
||||
RELEASE_RESOLC_WASM_URI: https://github.com/paritytech/revive-workflow-test/releases/download/${{ github.ref_name }}/resolc.wasm
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
@@ -226,11 +230,10 @@ jobs:
|
||||
retention-days: 1
|
||||
|
||||
create-release:
|
||||
if: github.event_name != 'pull_request'
|
||||
if: startsWith(github.ref_name, 'v')
|
||||
needs: [check-version-changed, build-wasm]
|
||||
runs-on: macos-14
|
||||
permissions:
|
||||
contents: write
|
||||
environment: tags
|
||||
steps:
|
||||
- name: Download Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
@@ -246,6 +249,12 @@ jobs:
|
||||
chmod +x resolc-x86_64-unknown-linux-musl
|
||||
chmod +x resolc-universal-apple-darwin
|
||||
|
||||
- uses: actions/create-github-app-token@v1
|
||||
id: app-token
|
||||
with:
|
||||
app-id: ${{ secrets.REVIVE_RELEASE_APP_ID }}
|
||||
private-key: ${{ secrets.REVIVE_RELEASE_APP_KEY }}
|
||||
|
||||
- name: create-release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
@@ -255,9 +264,10 @@ jobs:
|
||||
|
||||
## Note for macOS Users
|
||||
The macOS binary is unsigned and it needs to be made runnable using `xattr -c resolc-universal-apple-darwin`.
|
||||
tag_name: ${{ needs.check-version-changed.outputs.PKG_VER }}
|
||||
name: ${{ needs.check-version-changed.outputs.PKG_VER }}
|
||||
draft: true
|
||||
tag_name: ${{ github.ref_name }}
|
||||
name: ${{ github.ref_name }}
|
||||
prerelease: true
|
||||
token: ${{ steps.app-token.outputs.token }}
|
||||
target_commitish: ${{ github.sha }}
|
||||
files: |
|
||||
resolc-x86_64-unknown-linux-musl
|
||||
|
||||
Reference in New Issue
Block a user