-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: autogenerate github release each friday
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -u | ||
|
||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
--github-token) | ||
GITHUB_TOKEN="$2" | ||
shift # pop option | ||
shift # pop value | ||
;; | ||
-*|--*) | ||
echo "Unknown option $1" | ||
exit 1 | ||
;; | ||
*) | ||
echo "Unknown argument $1" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
CURRENT_VERSION=$(git describe --abbrev=0 --tags 2>/dev/null) | ||
CURRENT_VERSION_PARTS=(${CURRENT_VERSION//./ }) | ||
FIRST_PART=${CURRENT_VERSION_PARTS[0]:1} | ||
SECOND_PART=${CURRENT_VERSION_PARTS[1]} | ||
COMMIT_ID=$(git rev-parse HEAD~0) | ||
YEAR="$(date +"%Y")" | ||
|
||
echo "Git tag: $CURRENT_VERSION" | ||
echo "First part: $FIRST_PART" | ||
echo "Second part: $SECOND_PART" | ||
echo "Second part+1: $(($SECOND_PART+1))" | ||
echo "Commit ID: $COMMIT_ID" | ||
echo "-------------------------------------" | ||
echo "Year: $YEAR" | ||
echo "-------------------------------------" | ||
|
||
|
||
# Ensure that the version starts from 0 when the year changes | ||
if [[ "$YEAR" == "$FIRST_PART" ]]; then | ||
# Increment the second part of the version by 1 | ||
NEW_VERSION="v${YEAR}.$(($SECOND_PART+1))" | ||
else | ||
# New year - start from 0 | ||
NEW_VERSION="v${YEAR}.0" | ||
fi | ||
|
||
echo "New version: $NEW_VERSION" | ||
|
||
echo "{\"tag_name\":\"$NEW_VERSION\",\"name\":\"${NEW_VERSION}\",\"draft\":true,\"prerelease\":false,\"generate_release_notes\":true}" | ||
|
||
curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/altinn/altinn-studio/releases \ | ||
-d "{\"tag_name\":\"$NEW_VERSION\",\"name\":\"${NEW_VERSION}\",\"draft\":true,\"prerelease\":false,\"generate_release_notes\":true}" | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Generate release for Altinn Studio | ||
on: | ||
schedule: | ||
# run every friday at 15:00 | ||
- cron: '0 9 * * 5' | ||
|
||
jobs: | ||
generate-release: | ||
name: Run release script | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
path: altinn-studio | ||
fetch-tags: true | ||
|
||
- name: Run release script | ||
working-directory: altinn-studio | ||
run: | | ||
bash .github/scripts/release.sh \ | ||
--github-token ${{ secrets.GITHUB_TOKEN }} \ | ||