Skip to content

Weekly Release

Weekly Release #47

Workflow file for this run

name: Weekly Release
on:
workflow_dispatch:
schedule:
# At 00:00 on Monday
- cron: "0 0 * * 1"
jobs:
bump-version-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: main
fetch-depth: 0 # Fetch all history for all branches and tags
# Requires "Read and Write access to code" permission
token: ${{ secrets.RELEASE_ACTION_ACCESS_TOKEN }}
- name: Fetch latest release version tag
id: fetch_tag
run: |
LATEST_VERSION=$(curl -s https://api.github.com/repos/gnosis/solvers/releases/latest | jq -r '.tag_name')
if ! [[ "$LATEST_VERSION" =~ ^v[0-9]+\.[0-9]+\..* ]]; then
echo "Invalid tag format, cannot bump version of: $LATEST_VERSION"
exit 1
fi
echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT
- name: Check for changes since last tag
run: |
git diff --quiet ${{ steps.fetch_tag.outputs.latest }}..HEAD || echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
- name: No changes detected
if: env.CHANGES_DETECTED != 'true'
run: echo "No commits since previous release. Skipping release."
- name: Create Tag
id: tag_version
if: env.CHANGES_DETECTED == 'true'
run: |
MAJOR=$(echo ${{ steps.fetch_tag.outputs.latest }} | cut -d. -f1)
MINOR=$(echo ${{ steps.fetch_tag.outputs.latest }} | cut -d. -f2)
NEW_MINOR=$((MINOR+1))
NEW_TAG="${MAJOR}.${NEW_MINOR}.0"
echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT
git tag $NEW_TAG
git push origin --tags
- name: "Create release"
if: env.CHANGES_DETECTED == 'true'
uses: "actions/github-script@v6"
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
try {
const response = await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: "Weekly Release ${{ steps.tag_version.outputs.tag }}",
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: "${{ steps.tag_version.outputs.tag }}",
});
core.exportVariable('RELEASE_ID', response.data.id);
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url);
} catch (error) {
core.setFailed(error.message);
}