|
| 1 | +# Publishes the core libraries to the CodeQL package registry. |
| 2 | +name: Publish CodeQL core libraries |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - '.github/workflows/pack-publisher.yml' # for testing changes to this workflow |
| 7 | + |
| 8 | + workflow_dispatch: |
| 9 | + # the cli to use, or blank to build it again |
| 10 | + # the pre-built packs, or blank to build again |
| 11 | + inputs: |
| 12 | + packages-build-number: |
| 13 | + description: | |
| 14 | + A CodeQL CLI workflow run number to download the packages artifacts from. |
| 15 | + Leave blank to build packages from this repository. |
| 16 | + default: '' |
| 17 | + required: false |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: write |
| 21 | + |
| 22 | +jobs: |
| 23 | + codeql-package-publish: |
| 24 | + environment: codeql-package-publish |
| 25 | + name: CodeQL Package - Publish |
| 26 | + runs-on: ubuntu-20.04 |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Dump environment |
| 30 | + run: env |
| 31 | + - name: Dump GitHub event context |
| 32 | + env: |
| 33 | + GITHUB_CONTEXT: '${{ toJson(github.event) }}' |
| 34 | + run: echo "$GITHUB_CONTEXT" |
| 35 | + |
| 36 | + - name: Checkout repository |
| 37 | + uses: actions/checkout@v2 |
| 38 | + |
| 39 | + # TODO add a way to specify different versions of the CLI |
| 40 | + - name: Download CLI |
| 41 | + uses: ./.github/actions/fetch-codeql |
| 42 | + with: |
| 43 | + use-bundle: 'true' |
| 44 | + |
| 45 | + - name: Publish packs |
| 46 | + run: | |
| 47 | + set -exu |
| 48 | + # do not publish go or suite-helpers |
| 49 | + # `ls` all directories in the bundle remove suite-helpers and go |
| 50 | + PACK_FOLDERS_TO_PUBLISH="$(ls -d $RUNNER_TEMP/codeql/qlpacks/codeql/*/* | grep -v suite | grep -v "\-go")" |
| 51 | + ARCHIVES="$RUNNER_TEMP/archives" |
| 52 | +
|
| 53 | + mkdir -p "$ARCHIVES" |
| 54 | +
|
| 55 | + echo "Running on: $PACK_FOLDERS_TO_PUBLISH" |
| 56 | +
|
| 57 | + # tgz each folder |
| 58 | + # then run pack publish on it |
| 59 | + for folder in $PACK_FOLDERS_TO_PUBLISH |
| 60 | + do |
| 61 | + echo "Archiving $folder for publishing" |
| 62 | + tar cfz "$ARCHIVES/archive.tgz" -C "$folder" . |
| 63 | + echo "Publishing $ARCHIVES/archive.tgz" |
| 64 | + echo "Would have run: 'codeql pack publish --file "$ARCHIVES/archive.tgz"'" |
| 65 | + done |
| 66 | +
|
| 67 | + - name: Bump versions |
| 68 | + run: | |
| 69 | + echo "Would have run 'codeql pack release'" |
| 70 | +
|
| 71 | + - name: Update git config |
| 72 | + run: | |
| 73 | + git config --global user.email "[email protected]" |
| 74 | + git config --global user.name "github-actions[bot]" |
| 75 | +
|
| 76 | + - name: Create PR |
| 77 | + run: | |
| 78 | + git add . |
| 79 | + git commit -m "Post-release preparation" |
| 80 | + NEW_BRANCH="post-release-prep-$(git show -s --format=%h)" |
| 81 | + git checkout -b $NEW_BRANCH |
| 82 | + gh pr create |
| 83 | + --head "$NEW_BRANCH" \ |
| 84 | + --base "$GITHUB_BASE_REF" \ |
| 85 | + --fill |
| 86 | + --draft |
0 commit comments