Skip to content

Commit

Permalink
chore: use semantic-release directly
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen committed Jul 9, 2024
1 parent 0b15c74 commit f84a6bf
Show file tree
Hide file tree
Showing 6 changed files with 2,467 additions and 210 deletions.
67 changes: 0 additions & 67 deletions .github/workflows/copy-to-d2-ci.yml

This file was deleted.

136 changes: 136 additions & 0 deletions .github/workflows/publish-d2-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: 'publish build to d2-ci'

on:
push:
branches:
- master
tags:
- '*'

env:
GIT_AUTHOR_NAME: '@dhis2-bot'
GIT_AUTHOR_EMAIL: '[email protected]'
GIT_COMMITTER_NAME: '@dhis2-bot'
GIT_COMMITTER_EMAIL: '[email protected]'
GH_TOKEN: ${{secrets.DHIS2_BOT_GITHUB_TOKEN}}
CI: true

jobs:
publish-to-d2-ci:
if: |
${{ !github.event.push.repository.fork }} &&
${{ startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/master' && contains(github.event.head_commit.message, '[skip release]')) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Install
run: yarn install --frozen-lockfile

- name: Build
run: yarn d2-app-scripts build

- name: Copy build to d2-ci
uses: dhis2/deploy-build@master
with:
build-dir: build/app
github-token: ${{ secrets.DHIS2_BOT_GITHUB_TOKEN }}

report-release-failure:
runs-on: ubuntu-latest
needs: publish-to-d2-ci
if: ${{ failure() && !cancelled() }}
steps:
- name: Checkout code
uses: actions/checkout@master

- name: Extract version
id: extract_version
uses: Saionaro/[email protected]

- name: Send failure message to analytics-internal-bot slack channel
id: slack
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
payload: |
{
"text": ":small_red_triangle_down: :maps-app: Maps release <https://github.com/dhis2/maps-app/actions/workflows/dhis2-verify-app.yml?query=branch%3Amaster+is%3Afailure|failed>",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":small_red_triangle_down: :maps-app: Maps release <https://github.com/dhis2/maps-app/actions/workflows/dhis2-verify-app.yml?query=branch%3Amaster+is%3Afailure|failed>"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

report-release-success:
runs-on: ubuntu-latest
needs: publish-to-d2-ci
if: ${{ success() && !cancelled() && github.ref == 'refs/heads/master' }}
steps:
- name: Checkout code
uses: actions/checkout@master

- name: Extract version
id: extract_version
uses: Saionaro/[email protected]

- name: Send success message to analytics-internal-bot slack channel
id: slack
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
payload: |
{
"text": "Maps app release ${{ steps.extract_version.outputs.version }} succeeded",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":large_green_circle: :maps-app: Maps version ${{ steps.extract_version.outputs.version }} released :tada:",
"emoji": true
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Release Notes*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ${{ toJSON(github.event.head_commit.message) }}
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Link to <https://github.com/dhis2/maps-app/actions/workflows/dhis2-verify-app.yml?query=branch%3Amaster+is%3Asuccess|build>"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
91 changes: 7 additions & 84 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
GIT_COMMITTER_NAME: '@dhis2-bot'
GIT_COMMITTER_EMAIL: '[email protected]'
GH_TOKEN: ${{secrets.DHIS2_BOT_GITHUB_TOKEN}}
D2_APP_HUB_TOKEN: ${{secrets.DHIS2_BOT_APPHUB_TOKEN}}
CI: true

jobs:
Expand Down Expand Up @@ -40,14 +41,6 @@ jobs:
- name: Build
run: yarn d2-app-scripts build

- uses: actions/upload-artifact@v3
with:
name: app-build
path: |
**/build
!**/node_modules
retention-days: 1

lint:
if: ${{ !contains(github.event.head_commit.message, '[skip release]') }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -119,25 +112,16 @@ jobs:
with:
node-version: 18.x

- uses: actions/download-artifact@v3
with:
name: app-build

- name: Install
run: yarn install --frozen-lockfile

- uses: dhis2/action-semantic-release@master
with:
publish-apphub: true
publish-github: true
github-token: ${{ secrets.DHIS2_BOT_GITHUB_TOKEN }}
apphub-token: ${{ secrets.DHIS2_BOT_APPHUB_TOKEN }}
- name: Run Semantic Release
run: npx -p [email protected] semantic-release
env:
GITHUB_TOKEN: ${{ secrets.DHIS2_BOT_GITHUB_TOKEN }}

- name: Copy bundle to d2-ci
uses: dhis2/deploy-build@master
with:
build-dir: build/app
github-token: ${{ secrets.DHIS2_BOT_GITHUB_TOKEN }}
- name: Publish to AppHub
run: yarn run d2-app-scripts publish

report-release-failure:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -171,64 +155,3 @@ jobs:
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

report-release-success:
runs-on: ubuntu-latest
needs: release
if: ${{ success() && !cancelled() }}
steps:
- name: Checkout code
uses: actions/checkout@master

- name: Extract version
id: extract_version
uses: Saionaro/[email protected]

- name: Send success message to analytics-internal-bot slack channel
id: slack
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
payload: |
{
"text": "Maps app release ${{ steps.extract_version.outputs.version }} succeeded",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":large_green_circle: :maps-app: Maps version ${{ steps.extract_version.outputs.version }} released :tada:",
"emoji": true
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Release Notes*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ${{ toJSON(github.event.head_commit.message) }}
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Link to <https://github.com/dhis2/maps-app/actions/workflows/dhis2-verify-app.yml?query=branch%3Amaster+is%3Asuccess|build>"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
38 changes: 38 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"branches": [
"master"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
[
"@semantic-release/exec",
{
"prepareCmd": "yarn build"
}
],
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md",
"package.json"
],
"message": "chore(release): cut ${nextRelease.version} [skip release]\n\n${nextRelease.notes}"
}
],
[
"@semantic-release/github",
{
"assets": [
{
"path": "build/bundle/*.zip",
"label": "DHIS2 app bundle"
}
]
}
]
]
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"@dhis2/cli-style": "^10.5.1",
"@dhis2/cypress-commands": "^10.0.3",
"@dhis2/cypress-plugins": "^10.0.3",
"@semantic-release/changelog": "^6",
"@semantic-release/exec": "^6",
"@semantic-release/git": "^10",
"@testing-library/react": "^12.1.5",
"cypress": "^12.16.0",
"cypress-tags": "^1.1.2",
Expand All @@ -34,6 +37,7 @@
"patch-package": "^6.5.1",
"redux-devtools": "^3.7.0",
"redux-mock-store": "^1.5.4",
"semantic-release": "^20",
"start-server-and-test": "^2.0.3"
},
"dependencies": {
Expand Down
Loading

0 comments on commit f84a6bf

Please sign in to comment.