Skip to content

Commit 13bddeb

Browse files
committed
chore(action): Rework action to be a composite action
- Removed docker image and workflow around it - Externalizing `@sentry/cli` so it can be installed per-runner - Support versioning of actions publishing major, minor and patch tags allowing users to pin versions - Reduce action run time by 80% as a result Closes: #185, #193, #233
1 parent 5d153c1 commit 13bddeb

File tree

18 files changed

+124180
-485
lines changed

18 files changed

+124180
-485
lines changed

.craft.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,5 @@ preReleaseCommand: bash scripts/craft-pre-release.sh
44
artifactProvider:
55
name: none
66
targets:
7-
- id: release
8-
name: docker
9-
source: ghcr.io/getsentry/action-release-image
10-
target: ghcr.io/getsentry/action-release-image
11-
- id: latest
12-
name: docker
13-
source: ghcr.io/getsentry/action-release-image
14-
target: ghcr.io/getsentry/action-release-image
15-
targetFormat: '{{{target}}}:latest'
167
- name: github
178
tagPrefix: v

.dockerignore

Lines changed: 0 additions & 10 deletions
This file was deleted.

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

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Releases always publish a `v[major].[minor].[patch]` tag
2+
# This action creates/updates `v[major]` and `v[major].[minor]` tags
3+
name: Create release tags
4+
5+
on:
6+
release:
7+
types: [released]
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
create-tags:
14+
name: Create release tags for major and minor versions
15+
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
ref: ${{ github.event.release.tag_name }}
22+
23+
- name: Set git user to getsentry-bot
24+
run: |
25+
echo "GIT_COMMITTER_NAME=getsentry-bot" >> $GITHUB_ENV;
26+
echo "GIT_AUTHOR_NAME=getsentry-bot" >> $GITHUB_ENV;
27+
echo "[email protected]" >> $GITHUB_ENV;
28+
29+
- name: Create and push major and minor version tags
30+
run: |
31+
MAJOR_VERSION=$(echo '${{ github.event.release.tag_name }}' | cut -d. -f1)
32+
MINOR_VERSION=$(echo '${{ github.event.release.tag_name }}' | cut -d. -f1-2)
33+
git tag -f $MAJOR_VERSION
34+
git tag -f $MINOR_VERSION
35+
git push -f origin $MAJOR_VERSION $MINOR_VERSION

.github/workflows/release.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
name: "Action: Prepare Release"
1+
name: Prepare Release
2+
23
on:
34
workflow_dispatch:
45
inputs:
@@ -12,10 +13,13 @@ on:
1213
description: Target branch to merge into. Uses the default branch as a fallback (optional)
1314
required: false
1415
default: master
16+
1517
jobs:
1618
release:
19+
name: Release a new version
20+
1721
runs-on: ubuntu-20.04
18-
name: 'Release a new version'
22+
1923
steps:
2024
- name: Get auth token
2125
id: token

.github/workflows/test.yml

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
name: "integration tests"
1+
name: Integration Tests
2+
23
on:
34
pull_request:
45
paths-ignore:
5-
- '**.md'
6+
- "**.md"
67
push:
78
branches:
89
- master
10+
- release/**
11+
paths-ignore:
12+
- "**.md"
13+
914
env:
1015
# Variables defined in the repository
1116
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
12-
# For master we have an environment variable that selects the action-release project
17+
# For master, we have an environment variable that selects the action-release project
1318
# instead of action-release-prs
1419
# For other branches: https://sentry-ecosystem.sentry.io/releases/?project=4505075304693760
1520
# For master branch: https://sentry-ecosystem.sentry.io/releases/?project=6576594
@@ -21,69 +26,64 @@ jobs:
2126
#
2227
# Secrets on this repo do not get shared with PRs opened on a fork, thus,
2328
# add SENTRY_AUTH_TOKEN as a secret to your fork if you want to use this job.
24-
# Checkout the README.md on how to create the internal integration (read: auth token)
2529
create-real-release-per-push:
26-
name: "Test current action"
27-
runs-on: ubuntu-latest
28-
# XXX: This job will fail for forks, skip step on forks and let contributors tweak it when ready
29-
if: github.ref != 'refs/heads/master'
30+
strategy:
31+
matrix:
32+
os: [ ubuntu-latest, windows-latest, macos-latest ]
33+
runs-on: ${{ matrix.os }}
34+
name: Test current action
3035
steps:
31-
- uses: actions/checkout@v3
32-
with:
33-
fetch-depth: 0
34-
# For PRs, this supports creating a release using the commits from the branch (rather than the merge commit)
35-
ref: ${{ github.event.pull_request.head.sha || github.sha }}
36+
- uses: actions/checkout@v4
37+
with:
38+
fetch-depth: 0
3639

37-
# This allows executing the action's code in the next step rather than a specific tag
38-
- uses: './.github/actions/use-local-dockerfile'
40+
- name: Create a staging release
41+
uses: ./
42+
env:
43+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
44+
SENTRY_LOG_LEVEL: debug
45+
with:
46+
ignore_missing: true
3947

40-
- name: Create a staging release
41-
uses: ./
42-
env:
43-
# If you want this step to be mocked you can uncomment this variable
44-
# MOCK: true
45-
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
46-
SENTRY_LOG_LEVEL: debug
47-
with:
48-
ignore_missing: true
49-
50-
mock-release: # Make sure that the action works on a clean machine without building Docker
51-
name: "Build image & mock a release"
52-
runs-on: ubuntu-latest
48+
mock-release:
49+
strategy:
50+
matrix:
51+
os: [ ubuntu-latest, windows-latest, macos-latest ]
52+
runs-on: ${{ matrix.os }}
53+
name: Mock a release
5354
steps:
54-
- uses: actions/checkout@v3
55-
56-
- uses: './.github/actions/use-local-dockerfile'
55+
- uses: actions/checkout@v3
56+
with:
57+
fetch-depth: 0
5758

58-
- name: Mock creating a Sentry release
59-
uses: ./
60-
env:
61-
MOCK: true
62-
with:
63-
environment: production
59+
- name: Mock creating a Sentry release
60+
uses: ./
61+
env:
62+
MOCK: true
63+
with:
64+
environment: production
6465

6566
mock-release-working-directory:
66-
name: "Build image & mock a release in a different working directory"
67-
runs-on: ubuntu-latest
67+
strategy:
68+
matrix:
69+
os: [ ubuntu-latest, windows-latest, macos-latest ]
70+
runs-on: ${{ matrix.os }}
71+
name: Mock a release in a different working directory
6872
steps:
69-
- name: Checkout directory we'll be running from
70-
uses: actions/checkout@v3
71-
with:
72-
path: main/
73-
74-
- name: Checkout directory we'll be testing
75-
uses: actions/checkout@v3
76-
with:
77-
path: test/
73+
- name: Checkout directory we'll be running from
74+
uses: actions/checkout@v3
75+
with:
76+
path: main/
7877

79-
- uses: './main/.github/actions/use-local-dockerfile'
80-
with:
81-
working_directory: main
78+
- name: Checkout directory we'll be testing
79+
uses: actions/checkout@v3
80+
with:
81+
path: test/
8282

83-
- name: Mock creating a Sentry release in a different directory
84-
uses: ./main
85-
env:
86-
MOCK: true
87-
with:
88-
environment: production
89-
working_directory: ./test
83+
- name: Mock creating a Sentry release in a different directory
84+
uses: ./main
85+
env:
86+
MOCK: true
87+
with:
88+
environment: production
89+
working_directory: ./test

.github/workflows/verify-dist.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Inspired by @action/checkout
2+
#
3+
# Compares the checked in `dist/index.js` with the PR's `dist/index.js`
4+
# On mismatch this action fails
5+
name: Verify dist
6+
7+
on:
8+
push:
9+
branches:
10+
- master
11+
paths-ignore:
12+
- "**.md"
13+
pull_request:
14+
paths-ignore:
15+
- "**.md"
16+
17+
jobs:
18+
check-dist:
19+
name: Verify dist/index.js file
20+
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Use volta
29+
uses: volta-cli/action@v4
30+
31+
- name: Install dependencies
32+
run: yarn install
33+
34+
- name: Rebuild dist
35+
run: yarn build
36+
37+
- name: Compare expected and actual dist
38+
run: |
39+
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
40+
echo "Detected uncommitted changes after build. Did you forget to commit `dist/index.js`?"
41+
echo "Diff:"
42+
git diff
43+
exit 1
44+
fi

0 commit comments

Comments
 (0)