Release #83
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
schedule: | |
- cron: '0 12 * * *' # Runs every day at 12:00 PM UTC | |
workflow_dispatch: # Allow manual trigger | |
jobs: | |
release: | |
runs-on: macos-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.DLIBPHONENUMBER_TOKEN }} | |
- name: Check for new libphonenumber release | |
run: | | |
# Fetch the latest release id | |
latest_release_id=$(curl -s \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.DLIBPHONENUMBER_TOKEN }}" \ | |
https://api.github.com/repos/google/libphonenumber/releases/latest | jq -r '.id') | |
# Log the fetched release id. | |
echo "latest release id: $latest_release_id" | |
# Check if latest_release_id is "null" and exit. | |
if [ "$latest_release_id" = "null" ]; then | |
# If there is a failure to fetch the latest libphonenumber release id, | |
# create a new GitHub (skip_steps) environment variable and set its value to (true). | |
echo "skip_steps=true" >> $GITHUB_ENV | |
echo "Failed to retrieve the latest release ID." | |
exit 0 | |
fi | |
# The current libphonenumber release id is stored here. | |
filename="./source_release_id" | |
# Check if the file exists | |
if [ -f "$filename" ]; then | |
current_release_id=$(cat "$filename") | |
# Exit if current release ID is the same as the latest release ID. | |
if [ "$current_release_id" -eq "$latest_release_id" ]; then | |
# If there is no new release, create a new GitHub (skip_steps) | |
# environment variable and set its value to (true). | |
echo "skip_steps=true" >> $GITHUB_ENV | |
echo "No new release has been published yet." | |
exit 0 | |
else | |
# Update the file with the latest release ID. | |
echo "$latest_release_id" > "$filename" | |
fi | |
else | |
# If it does not exist, create the file and update it with the latest release ID. | |
touch "$filename" | |
echo "$latest_release_id" > "$filename" | |
fi | |
- name: Set-up Dart | |
if: env.skip_steps != 'true' | |
uses: dart-lang/setup-dart@v1 | |
- name: Install package dependencies | |
if: env.skip_steps != 'true' | |
run: dart pub get | |
- name: Run update resources script | |
if: env.skip_steps != 'true' | |
run: ./update_resources.sh |