Skip to content

Commit cdf51a6

Browse files
committed
Add workflow to push weekly tags
1 parent d98e734 commit cdf51a6

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

.github/workflows/tag.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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:23 UTC, using a odd time avoids jobs
19+
# from being skipped during peak hours.
20+
- cron: 23 9 * * 5
21+
workflow_dispatch:
22+
inputs:
23+
commit:
24+
description: Which commit to tag
25+
required: true
26+
27+
patch-version:
28+
description: Additional version component
29+
required: false
30+
default: '00'
31+
32+
permissions: {}
33+
34+
jobs:
35+
create-date-tag:
36+
runs-on: ubuntu-latest
37+
permissions:
38+
contents: write # required to push tag
39+
checks: read
40+
env:
41+
COMMIT: ${{ inputs.commit || github.sha }}
42+
43+
steps:
44+
- name: Checkout repository
45+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
46+
with:
47+
fetch-depth: 0
48+
persist-credentials: true
49+
50+
- name: Set up Git
51+
run: |
52+
git config user.name "github-actions[bot]"
53+
git config user.email "github-actions[bot]@users.noreply.github.com"
54+
55+
- name: Check CI Status
56+
# Allow manual triggered workflows to circumvent the check
57+
if: ${{ github.event_name != 'workflow_dispatch' }}
58+
env:
59+
GH_TOKEN: ${{ github.token }}
60+
run: |
61+
# This `gh` invocation returns a json array with the workflow status like this
62+
# [ { "status": "completed" } ]
63+
# If the workflow wasn't success full the array will be empty which we check for
64+
# using `grep` -q = set exit code -v = invert match
65+
gh run list --commit "$COMMIT" \
66+
--workflow "Linux Build using GCC" \
67+
--status success --json status | grep -qv '\[\]'
68+
69+
- name: Create and push date-version tag
70+
env:
71+
PATCH_VERSION: ${{ inputs.patch-version || '00' }}
72+
run: |
73+
MESSAGE="This is convenience tag, not a full release."
74+
DATE_TAG=$(date -u +"v%Y.%m.%d.$PATCH_VERSION")
75+
git tag -m "$MESSAGE" "$DATE_TAG" "$COMMIT"
76+
git push origin "$DATE_TAG"

0 commit comments

Comments
 (0)