Skip to content

Commit 2419bd7

Browse files
committed
ci: bump version workflow
1 parent cf10e39 commit 2419bd7

File tree

3 files changed

+128
-2
lines changed

3 files changed

+128
-2
lines changed

.github/workflows/bump-version.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: "Release: Bump Version"
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
bump-version:
8+
runs-on: ubuntu-latest
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
env:
15+
BRANCH: ci/bump-version
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Create GitHub App token
22+
uses: actions/create-github-app-token@v2
23+
id: app-token
24+
with:
25+
app-id: ${{ vars.APP_ID }}
26+
private-key: ${{ secrets.APP_KEY }}
27+
28+
- name: Get GitHub App User ID
29+
id: get-user-id
30+
shell: bash
31+
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
32+
env:
33+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
34+
35+
- name: Git Config
36+
shell: bash
37+
run: |
38+
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
39+
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
40+
41+
- name: Bump Version
42+
id: bump-version
43+
env:
44+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
45+
COMMIT: "ci: bump version for release :rocket:"
46+
shell: bash
47+
run: |
48+
if git show-ref --quiet refs/heads/${BRANCH}; then
49+
echo "Branch ${BRANCH} already exists."
50+
git branch -D "${BRANCH}"
51+
git push origin --delete "${BRANCH}"
52+
fi
53+
git checkout -b "${BRANCH}"
54+
DATE=$(date +%Y-%m-%d)
55+
VERSION=$(date +%Y.%m.%d)
56+
sed -i "s/^version:.*/version: ${VERSION}/" CITATION.cff
57+
sed -i "s/^date-released:.*/date-released: \"${DATE}\"/" CITATION.cff
58+
git add CITATION.cff || echo "No changes to add"
59+
git commit -m "${COMMIT}" || echo "No changes to commit"
60+
git push --force origin ${BRANCH} || echo "No changes to push"
61+
62+
- name: Create Pull Request
63+
shell: bash
64+
env:
65+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
66+
run: |
67+
sleep 20
68+
gh pr create --fill-first --base "main" --head "${BRANCH}" --label "Type: CI/CD :robot:"
69+
sleep 5
70+
gh pr merge --auto --squash --delete-branch

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "Release: Create Release"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- CITATION.cff
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
15+
permissions:
16+
contents: write
17+
id-token: write
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Create GitHub App token
24+
uses: actions/create-github-app-token@v2
25+
id: app-token
26+
with:
27+
app-id: ${{ vars.APP_ID }}
28+
private-key: ${{ secrets.APP_KEY }}
29+
30+
- name: Get GitHub App User ID
31+
id: get-user-id
32+
shell: bash
33+
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
34+
env:
35+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
36+
37+
- name: Git Config
38+
shell: bash
39+
run: |
40+
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
41+
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
42+
43+
- name: Update branch
44+
run: |
45+
git fetch --all
46+
git checkout main
47+
git pull origin main
48+
49+
- name: Release extension on GitHub
50+
env:
51+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
52+
shell: bash
53+
run: |
54+
DATE=$(grep "^date-released:" CITATION.cff | sed 's/date-released: //;s/"//g')
55+
VERSION=$(grep "^version:" CITATION.cff | sed 's/version: //;s/"//g')
56+
gh release create ${VERSION} --title ${DATE} --generate-notes

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ authors:
55
- family-names: "Canouil"
66
given-names: "Mickaël"
77
orcid: "https://orcid.org/0000-0002-3396-4549"
8-
date-released: "2025-06-22"
9-
version: 1.8.3
8+
date-released: "2025-06-30"
9+
version: 1.9.0
1010
url: "https://github.com/mcanouil/quarto-codespaces"
1111
repository-code: "https://github.com/mcanouil/quarto-codespaces"
1212
license: "MIT"

0 commit comments

Comments
 (0)