|
| 1 | +# Copyright (c) Facebook, Inc. and its affiliates. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +name: Weekly Date Tag |
| 15 | + |
| 16 | +on: |
| 17 | + schedule: |
| 18 | + # Runs every Friday at 09:00 UTC |
| 19 | + - cron: 0 9 * * 5 |
| 20 | + workflow_dispatch: |
| 21 | + inputs: |
| 22 | + commit: |
| 23 | + description: Which commit to tag |
| 24 | + required: true |
| 25 | + |
| 26 | + patch-version: |
| 27 | + description: Additional version component |
| 28 | + required: false |
| 29 | + default: '00' |
| 30 | + |
| 31 | +permissions: {} |
| 32 | + |
| 33 | +jobs: |
| 34 | + create-date-tag: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + permissions: |
| 37 | + contents: write # required to push tag |
| 38 | + checks: read |
| 39 | + env: |
| 40 | + COMMIT: ${{ inputs.commit || github.sha }} |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Checkout repository |
| 44 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 45 | + with: |
| 46 | + fetch-depth: 0 |
| 47 | + persist-credentials: true |
| 48 | + |
| 49 | + - name: Set up Git |
| 50 | + run: | |
| 51 | + git config user.name "github-actions[bot]" |
| 52 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 53 | +
|
| 54 | + - name: Check CI Status |
| 55 | + # Allow manual triggered workflows to circumvent the check |
| 56 | + if: ${{ github.event_name != 'workflow_dispatch' }} |
| 57 | + env: |
| 58 | + GH_TOKEN: ${{ github.token }} |
| 59 | + run: | |
| 60 | + # This `gh` invocation returns a json array with the workflow status like this |
| 61 | + # [ { "status": "completed" } ] |
| 62 | + # If the workflow wasn't success full the array will be empty which we check for |
| 63 | + # using `grep` -q = set exit code -v = invert match |
| 64 | + gh run list --commit "$COMMIT" \ |
| 65 | + --workflow "Linux Build using GCC" \ |
| 66 | + --status success --json status | grep -qv '\[\]' |
| 67 | +
|
| 68 | + - name: Create and push date-version tag |
| 69 | + env: |
| 70 | + PATCH_VERSION: ${{ inputs.patch-version || '00' }} |
| 71 | + run: | |
| 72 | + MESSAGE="This is convenience tag, not a full release." |
| 73 | + DATE_TAG=$(date -u +"v%Y.%m.%d.$PATCH_VERSION") |
| 74 | + git tag -m "$MESSAGE" "$DATE_TAG" "$COMMIT" |
| 75 | + git push origin "$DATE_TAG" |
0 commit comments