Skip to content

Commit e893f9d

Browse files
authored
feat: implement cd bund
1 parent d63250a commit e893f9d

37 files changed

Lines changed: 553 additions & 167 deletions
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Create Release PR
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
release_type:
6+
description: 'Select type of release'
7+
required: true
8+
type: choice
9+
default: patch
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
jobs:
19+
create_release_pr:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout develop branch
23+
uses: actions/checkout@v4
24+
with:
25+
ref: develop
26+
fetch-depth: 0
27+
28+
- name: Set up Git user
29+
run: |
30+
git config --global user.name "${GITHUB_ACTOR}"
31+
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
32+
33+
- name: Get Next Version
34+
id: nv
35+
run:
36+
echo "new_version=$(npx semver $(jq -r .version package.json) -i ${{ github.event.inputs.release_type }})" >> $GITHUB_OUTPUT
37+
38+
- name: Create release branch
39+
run: |
40+
RELEASE_BRANCH="release/${{ steps.nv.outputs.new_version }}"
41+
git checkout -b "$RELEASE_BRANCH" develop
42+
git push --set-upstream origin "$RELEASE_BRANCH"
43+
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: 22
48+
49+
- name: Install deps
50+
run: npm ci
51+
52+
- name: Update release version
53+
run: |
54+
RELEASE_BRANCH="release/${{ steps.nv.outputs.new_version }}"
55+
git status
56+
if [ -f package.json ]; then
57+
npm version ${{ steps.nv.outputs.new_version }} --no-git-tag-version
58+
git add package.json package-lock.json
59+
fi
60+
if [ -f publiccode.yml ]; then
61+
node scripts/ci/updatePubliccodeReleaseDate.js
62+
node scripts/ci/updatePubliccodeSoftwareVersion.js ${{ steps.nv.outputs.new_version }}
63+
git add publiccode.yml
64+
fi
65+
git commit -m "chore: bump version to ${{ steps.nv.outputs.new_version }}" || echo "No changes to commit"
66+
git push origin "$RELEASE_BRANCH"
67+
68+
- name: Create PR
69+
env:
70+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: |
72+
RELEASE_BRANCH="release/${{ steps.nv.outputs.new_version }}"
73+
git checkout "$RELEASE_BRANCH"
74+
gh pr create -t "chore: release ${{ steps.nv.outputs.new_version }}" -b "Release ${{ steps.nv.outputs.new_version }}. Both Package version and publiccode.yml are already updated. Don't forget to edit CHANGELOG.md" -B main -l release
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Recreate Dependabot PR on develop
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
branches:
7+
- main
8+
9+
jobs:
10+
rebase-dependabot-to-develop:
11+
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Git
19+
run: |
20+
git config user.name "github-actions[bot]"
21+
git config user.email "github-actions[bot]@users.noreply.github.com"
22+
23+
- name: Fetch full history and all branches
24+
run: git fetch --unshallow --all
25+
26+
- name: Create a new branch from develop with dependabot changes
27+
env:
28+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
run: |
30+
ORIGINAL_BRANCH="${{ github.event.pull_request.head.ref }}"
31+
NEW_BRANCH="dependabot-develop-${ORIGINAL_BRANCH}"
32+
33+
# Create new branch based on develop
34+
git checkout origin/develop -b $NEW_BRANCH
35+
36+
# Get last commit message from original Dependabot branch
37+
LAST_COMMIT_MSG=$(git log -1 --pretty=%B origin/$ORIGINAL_BRANCH)
38+
39+
# Merge Dependabot changes into the new branch
40+
git merge --no-commit origin/$ORIGINAL_BRANCH || true
41+
git commit -m "$LAST_COMMIT_MSG"
42+
git push origin $NEW_BRANCH
43+
44+
# Create new pull request against develop
45+
gh pr create \
46+
--base develop \
47+
--head $NEW_BRANCH \
48+
--title "${{ github.event.pull_request.title }} (rebased onto develop)" \
49+
--body "This is an automated copy of #${{ github.event.pull_request.number }}, targeting \`develop\` instead of \`main\`."
50+
51+
# Close the original PR
52+
gh pr close ${{ github.event.pull_request.number }} --comment "Automatically closed: a new PR has been created against \`develop\`."
53+
54+
# Delete the original Dependabot branch
55+
gh api \
56+
-X DELETE \
57+
repos/${{ github.repository }}/git/refs/heads/$ORIGINAL_BRANCH

.github/workflows/deploy.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
on:
22
push:
33
branches:
4-
- main
4+
- cd-bund
55

66
jobs:
77
deploy:
@@ -17,12 +17,9 @@ jobs:
1717
- run: npm ci
1818
- run: npm run build
1919
env:
20-
DEFAULT_COUNTRY_SECTION: italy
21-
ELASTIC_URL: "https://elasticsearch.developers.italia.it/indicepa_pec/_search"
20+
DEFAULT_COUNTRY_SECTION: switzerland
2221
- run: |
23-
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/italia/publiccode-editor.git
24-
echo publiccode-editor.developers.italia.it > dist/CNAME
25-
26-
npm run deploy -m "Automated deployment: ${CIRCLE_SHA1} [ci skip]"
22+
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/swiss/publiccode-editor.git
23+
npm run gdeploy -m "Automated deployment: ${CIRCLE_SHA1} [ci skip]"
2724
env:
2825
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Finish Release PR
2+
permissions:
3+
contents: write
4+
on:
5+
pull_request:
6+
branches:
7+
- main
8+
types:
9+
- closed
10+
11+
jobs:
12+
finish_release:
13+
if: startsWith(github.head_ref, 'release/') && github.event.pull_request.merged == true
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout main branch
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Git user
22+
run: |
23+
git config --global user.name "${GITHUB_ACTOR}"
24+
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
25+
26+
- name: Get Version
27+
id: v
28+
run: |
29+
echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
30+
- name: Attach a tag
31+
run: |
32+
git fetch
33+
git checkout main
34+
git tag v${{ steps.v.outputs.version }}
35+
git push origin main
36+
git push --tags
37+
- name: Merge to Develop
38+
run: |
39+
git fetch
40+
git checkout develop
41+
git merge --no-ff main -m "chore: release ${{ steps.v.outputs.version }}"
42+
git push origin develop
43+
- name: Create GitHub Release
44+
uses: softprops/action-gh-release@v2
45+
with:
46+
tag_name: v${{ steps.v.outputs.version }}
47+
name: Release ${{ steps.v.outputs.version }}
48+
body: "Automated release for tag v${{ steps.v.outputs.version }}"
49+
draft: false
50+
prerelease: false
51+
make_latest: true
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @olibrian

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
# publiccode yml Editor
2+
3+
This project is a fork of [italia/publiccode-editor](https://github.com/italia/publiccode-editor), customized to align with the Design System of the Swiss Confederation 🇨🇭.
4+
5+
For details about the Swiss Design System, see:
6+
7+
- [Design System for the Swiss Confederation (GitHub)](https://github.com/swiss/designsystem)
8+
- [Design System for the Swiss Confederation (Stoybook)](https://swiss.github.io/designsystem/?path=/docs/get-started--docs)
9+
- [Design System Core Library (Figma)](https://www.figma.com/design/3UYgqxmcJbG0hpWuti3y8U/🇨🇭Design-System-Core-Library)
10+
11+
The application is live at: https://puzzle.github.io/publiccode-editor/
12+
13+
Below is the original README for the Italian version.
14+
15+
---
16+
217
![Build Status](https://img.shields.io/circleci/project/github/italia/publiccode-editor/master.svg) ![Issues](https://img.shields.io/github/issues/italia/publiccode-editor.svg) ![License](https://img.shields.io/github/license/italia/publiccode-editor.svg) [![Join the #publiccode channel](https://img.shields.io/badge/Slack%20channel-%23publiccode-blue.svg?logo=slack)](https://developersitalia.slack.com/messages/CAM3F785T)
318
[![Get invited](https://slack.developers.italia.it/badge.svg)](https://slack.developers.italia.it/)
419

RELEASE.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# RELEASE
2+
3+
The release process is automated using Github Actions. This automated process mirrors the manual one currently used.
4+
5+
## Branch workflow
6+
7+
### Start a release
8+
9+
Everytime a new release starts, you have to run the action *create-release-pr*.
10+
It will ask if you wanna relase a patch, a minor or a major.
11+
After that, it will:
12+
13+
- Generate a new version of the package
14+
- Create a branch with this name release/*\<new-version>* starting from *develop*
15+
- It will update the *package.json*
16+
- It will update the *publiccode.yml*
17+
- It will open a PR on that branch
18+
19+
The PR process has the aim of giving the freedom to do manual editing.
20+
You MUST update *CHANGELOG.md* manually before closing the PR.
21+
22+
### Finishing a release
23+
24+
Another Github Action, *finish-release*, is triggered when the PR is closed on *main*.
25+
26+
This action will:
27+
28+
- Create a tag and push it
29+
- Merge *main* on *develop*
30+
- Create a *release package* on Github
31+
32+
It's highly recommended to edit manually the description of the release.
33+
It will be automated in the next releases.
34+
35+
## Future enhancements
36+
37+
This worfklow will be changed with the adoption of more solid and more robust solutions.

package-lock.json

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"build:wasm": "cp \"$(go env GOROOT)/misc/wasm/wasm_exec.js\" public && GOOS=js GOARCH=wasm go build -o public/main.wasm src/wasm/main.go",
1717
"serve": "rm -rf dist; npm run build && http-server dist",
1818
"test": "jest --passWithNoTests",
19+
"gdeploy": "gh-pages -u 'Deploy Bot <no-reply@puzzle.ch>' -d dist",
1920
"deploy": "gh-pages -u 'Deploy Bot <no-reply@teamdigitale.governo.it>' -d dist",
2021
"release": "release-it",
2122
"_postinstall": "patch-package"
@@ -27,7 +28,7 @@
2728
],
2829
"repository": {
2930
"type": "git",
30-
"url": "git@github.com:italia/publiccode-editor.git"
31+
"url": "git@github.com:puzzle/publiccode-editor.git"
3132
},
3233
"jest": {
3334
"moduleNameMapper": {
@@ -42,7 +43,7 @@
4243
"@uiw/react-md-editor": "^4.0.5",
4344
"accessible-autocomplete": "^3.0.1",
4445
"bootstrap": "^5.3.6",
45-
"bootstrap-italia": "^2.14.0",
46+
"bootstrap-switzerland": "puzzle/bootstrap-switzerland#gh-pages",
4647
"copy-to-clipboard": "^3.3.3",
4748
"countries-list": "^3.0.6",
4849
"date-fns": "^4.1.0",
529 Bytes
Loading

0 commit comments

Comments
 (0)