Skip to content

Commit 5e6fd0e

Browse files
andreiborzaLms24
andauthored
chore(release): Add craft publish workflow (#238)
* chore(release): Add craft publish workflow Previously, any push to `master` built and uploaded the action's underlying docker image to the GitHub registry under the `latest` tag. That meant, regardless of version specified in a user's workflow they'd get the latest change. The introduction of craft allows us to push versioned images to the registry and associate a release's action with that version. At the moment, this workflow does not incorporate tags for major (e.g. `v1`) and major.minor (e.g. `v1.2`). The ability to publish several git tags will probably have to be added to craft or publish directly. Closes: #129 * Revert action to use `latest` tag as we don't yet have any versioned images published * Update CHANGELOG.md Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io> * Update .github/workflows/release.yml Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io> --------- Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
1 parent f5a213d commit 5e6fd0e

File tree

11 files changed

+142
-64
lines changed

11 files changed

+142
-64
lines changed

.craft.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
minVersion: 0.23.1
2+
changelogPolicy: auto
3+
preReleaseCommand: bash scripts/craft-pre-release.sh
4+
targets:
5+
- id: release
6+
name: docker
7+
source: ghcr.io/getsentry/action-release-image
8+
target: getsentry/action-release
9+
- id: latest
10+
name: docker
11+
source: ghcr.io/getsentry/action-release-image
12+
target: getsentry/sentry
13+
targetFormat: '{{{target}}}:latest'
14+
- name: github
15+
tagPrefix: v

.github/actions/use-local-dockerfile/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ runs:
1212
shell: bash
1313
run: |
1414
mv ${{inputs.working_directory}}/action.yml ${{inputs.working_directory}}/previous.yml
15-
sed "s|docker://ghcr.io/getsentry/action-release-image:latest|Dockerfile|" ${{inputs.working_directory}}/previous.yml >> ${{inputs.working_directory}}/action.yml
15+
sed "s|docker://ghcr.io/getsentry/action-release-image:.*[^']|Dockerfile|" ${{inputs.working_directory}}/previous.yml >> ${{inputs.working_directory}}/action.yml
1616
grep "image" ${{inputs.working_directory}}/action.yml

.github/workflows/build.yml

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,22 @@ on:
33
push:
44
branches:
55
- master
6-
7-
env:
8-
# Variables defined in the repository
9-
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
10-
# For master we have an environment variable that selects the action-release project
11-
# instead of action-release-prs
12-
# For other branches: https://sentry-ecosystem.sentry.io/releases/?project=4505075304693760
13-
# For master branch: https://sentry-ecosystem.sentry.io/releases/?project=6576594
14-
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
6+
- release/**
7+
pull_request:
158

169
jobs:
1710
docker-build:
18-
name: Build & pubish Docker images
11+
name: Build & publish Docker images
1912
runs-on: ubuntu-latest
2013
permissions:
2114
packages: write
2215
strategy:
2316
matrix:
2417
target:
2518
- name: builder
26-
image: action-release-builder-image:latest
19+
image: action-release-builder-image
2720
- name: app
28-
image: action-release-image:latest
21+
image: action-release-image
2922
steps:
3023
- name: Checkout repo
3124
uses: actions/checkout@v3
@@ -56,20 +49,8 @@ jobs:
5649
uses: docker/build-push-action@v6
5750
with:
5851
platforms: linux/amd64,linux/arm64
59-
push: ${{ github.ref == 'refs/heads/master' }}
60-
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.target.image }}
61-
cache-from: ghcr.io/${{ github.repository_owner }}/${{ matrix.target.image }}
52+
push: true
53+
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.target.image }}:${{ github.sha }}
54+
cache-from: ghcr.io/${{ github.repository_owner }}/${{ matrix.target.image }}:latest
6255
target: ${{ matrix.target.name }}
6356
build-args: BUILDKIT_INLINE_CACHE=1
64-
65-
# This step creates real Sentry releases for the action itself:
66-
# https://sentry-ecosystem.sentry.io/releases/?project=6576594
67-
- name: Sentry Release
68-
uses: getsentry/action-release@v1
69-
if: vars.SENTRY_ORG != ''
70-
env:
71-
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
72-
SENTRY_LOG_LEVEL: debug
73-
with:
74-
environment: 'production'
75-
ignore_missing: true

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: "Action: Prepare Release"
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: Version to release
7+
required: true
8+
force:
9+
description: Force a release even when there are release-blockers (optional)
10+
required: false
11+
merge_target:
12+
description: Target branch to merge into. Uses the default branch as a fallback (optional)
13+
required: false
14+
default: master
15+
jobs:
16+
release:
17+
runs-on: ubuntu-20.04
18+
name: 'Release a new version'
19+
steps:
20+
- name: Get auth token
21+
id: token
22+
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0
23+
with:
24+
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
25+
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}
26+
27+
- uses: actions/checkout@v4
28+
with:
29+
token: ${{ steps.token.outputs.token }}
30+
fetch-depth: 0
31+
32+
- name: Prepare release
33+
uses: getsentry/action-prepare-release@v1
34+
env:
35+
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
36+
with:
37+
version: ${{ github.event.inputs.version }}
38+
force: ${{ github.event.inputs.force }}
39+
merge_target: ${{ github.event.inputs.merge_target }}

.prettierrc.json

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
{
2-
"printWidth": 80,
3-
"tabWidth": 2,
4-
"useTabs": false,
5-
"semi": true,
6-
"singleQuote": true,
7-
"trailingComma": "es5",
8-
"bracketSpacing": false,
9-
"arrowParens": "avoid",
10-
"parser": "typescript"
11-
}
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "es5",
8+
"bracketSpacing": false,
9+
"arrowParens": "avoid",
10+
"overrides": [
11+
{
12+
"files": "*.md",
13+
"options": {
14+
"proseWrap": "preserve"
15+
}
16+
}
17+
]
18+
}

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Changelog
2+
3+
## Unreleased
4+
5+
6+
## 1.9.0
7+
8+
** Important Changes **
9+
10+
- **feat(sourcemaps): Add inject option to inject debug ids into source files and sourcemaps (#229) **
11+
A new option to inject Debug IDs into source files and sourcemaps was added to the action to ensure proper un-minifaction of your stacktraces. We strongly recommend enabling this by setting inject: true in your action alongside providing a path to sourcemaps.
12+
13+
** Other Changes **
14+
- feat(telemetry): Collect project specific tags (#228)
15+
16+
## Previous Releases
17+
18+
For previous releases, check the [Github Releases](https://github.com/getsentry/action-release/releases) page.

action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ inputs:
5252
required: false
5353
runs:
5454
using: 'docker'
55-
# If you change this, update the use-local-dockerfile action
5655
image: 'docker://ghcr.io/getsentry/action-release-image:latest'
5756
branding:
5857
icon: 'triangle'

docs/development.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Development of `getsentry/action-release`
22

3-
This document aims to provide guidelines for maintainers and contains information on how to develop and test this action.
3+
This document aims to provide guidelines for maintainers and contains information on how to develop and test this action.
44
For info on how to release changes, follow [publishing-a-release](publishing-a-release.md).
55

66
## Development
@@ -20,7 +20,7 @@ You can run unit tests with `yarn test`.
2020
The first job in [test.yml](../.github/workflows/test.yml) has instructions on how to tweak a job in order to execute your changes as part of the PR.
2121

2222
> [!NOTE]
23-
> Contributors will need to create an internal integration in their Sentry org and need to be an admin.
23+
> Contributors will need to create an internal integration in their Sentry org and need to be an admin.
2424
> See [#Prerequisites](../README.md#prerequisites).
2525
2626
Members of this repo will not have to set anything up since [the integration](https://sentry-ecosystem.sentry.io/settings/developer-settings/end-to-end-action-release-integration-416eb2/) is already set-up. Just open the PR and you will see [a release created](https://sentry-ecosystem.sentry.io/releases/?project=4505075304693760) for your PR.
@@ -33,35 +33,37 @@ Members of this repo will not have to set anything up since [the integration](ht
3333
> [!NOTE]
3434
> Once we start producing Docker images for PRs we can get rid of the need of using the `sed` command below.
3535
36-
**Step 1**
37-
* Create a branch, make changes and push it
38-
* Run this command, commit the changes and push it
39-
* This will cause the action-release to be built using the `Dockerfile`
40-
* You will need to revert this change once your changes are approved and ready to be merged
36+
**Step 1**
37+
38+
- Create a branch, make changes and push it
39+
- Run this command, commit the changes and push it
40+
- This will cause the action-release to be built using the `Dockerfile`
41+
- You will need to revert this change once your changes are approved and ready to be merged
4142

4243
```shell
4344
sed -i .backup 's|docker://ghcr.io/getsentry/action-release-image:latest|Dockerfile|' action.yml
4445
```
4546

4647
**Step 2**
4748
Test out your action-release changes on your own repo.
48-
* Get the sha for the latest commit on **Step 1**
49-
* Modify your usage of action-release to point to that commit (if you're using a fork, edit the `getsentry` org in the string below)
49+
50+
- Get the sha for the latest commit on **Step 1**
51+
- Modify your usage of action-release to point to that commit (if you're using a fork, edit the `getsentry` org in the string below)
5052

5153
Example:
5254

5355
```yml
54-
- name: Sentry Release
55-
uses: getsentry/action-release@<latest commit sha>
56-
env:
57-
# You will remove this in the next steps when ready
58-
MOCK: true
59-
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
60-
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
61-
# If you specify a GitHub environment for the branch from where you create
62-
# releases from (e.g. master), you can then specify a repository-level variable
63-
# for all other branches. This allows using a second project for end-to-end testing
64-
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
56+
- name: Sentry Release
57+
uses: getsentry/action-release@<latest commit sha>
58+
env:
59+
# You will remove this in the next steps when ready
60+
MOCK: true
61+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
62+
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
63+
# If you specify a GitHub environment for the branch from where you create
64+
# releases from (e.g. master), you can then specify a repository-level variable
65+
# for all other branches. This allows using a second project for end-to-end testing
66+
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
6567
```
6668
6769
> [!NOTE]

docs/publishing-a-release.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ The [build.yml](../.github/workflows/build.yml) workflow will build a Docker ima
77
> Be extremely careful and intentional with changes and ensure properly testing them before merging, see [#Testing](development.md#testing) for more info.
88
99
> [!NOTE]
10-
> Unfortunately, we only use the `latest` tag for the Docker image, thus, making use of a version with the action ineffective (e.g. `v1` vs `v1.3.0`).
10+
> Unfortunately, we only use the `latest` tag for the Docker image, thus, making use of a version with the action ineffective (e.g. `v1` vs `v1.3.0`).
1111
> See #129 on how to fix this.
1212
1313
> [!NOTE]
14-
> At the moment our Docker image publishing is decoupled from `tag` creation in the repository.
15-
> We should only publish a specific Docker tag when we create a tag (you can make GitHub workflows listen to this). See #102 for details.
14+
> At the moment our Docker image publishing is decoupled from `tag` creation in the repository.
15+
> We should only publish a specific Docker tag when we create a tag (you can make GitHub workflows listen to this). See #102 for details.
1616
> Once this is fixed, merges to `master` will not make the Docker image live.
1717
1818
When you are ready to make a release, open a [new release checklist issue](https://github.com/getsentry/action-release/issues/new?assignees=&labels=&template=release-checklist.md&title=New+release+checklist+for+%5Bversion+number%5D) and follow the steps in there.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"main": "dist/index.js",
77
"scripts": {
88
"build": "ncc build src/main.ts",
9-
"format": "prettier --write **/*.ts",
10-
"format-check": "prettier --check **/*.ts",
9+
"format": "prettier --write **/*.ts **/*.md",
10+
"format-check": "prettier --check **/*.ts **/*.md",
1111
"lint": "eslint src/**/*.ts",
1212
"test": "jest",
1313
"all": "yarn run format && yarn run lint && yarn run build && yarn test"

0 commit comments

Comments
 (0)