|
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - main |
| 7 | + - "beta/**" |
7 | 8 |
|
8 | 9 | pull_request: |
| 10 | + types: [opened, synchronize, reopened] |
9 | 11 | branches: |
10 | 12 | - main |
11 | 13 |
|
@@ -99,6 +101,135 @@ jobs: |
99 | 101 | run: | |
100 | 102 | make test.artifacts |
101 | 103 |
|
| 104 | + determine-version: |
| 105 | + runs-on: ubuntu-22.04 |
| 106 | + outputs: |
| 107 | + version_tag: ${{ steps.version.outputs.tag }} |
| 108 | + is_beta: ${{ steps.version.outputs.is_beta }} |
| 109 | + steps: |
| 110 | + - name: Checkout |
| 111 | + uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 112 | + with: |
| 113 | + ref: ${{ github.head_ref || github.ref }} |
| 114 | + |
| 115 | + - name: Determine version tag |
| 116 | + id: version |
| 117 | + run: | |
| 118 | + if [[ "${{ github.head_ref }}" != release-please--branches--* ]] && [[ "${{ github.ref }}" != refs/heads/beta/* ]]; then |
| 119 | + echo "Not a candidate for a beta release" |
| 120 | + echo "is_beta=false" >> $GITHUB_OUTPUT |
| 121 | + exit 0 |
| 122 | + fi |
| 123 | +
|
| 124 | + VERSION=$(jq -r '.version' package.json) |
| 125 | +
|
| 126 | + # Determine context: beta push or release-please PR |
| 127 | + if [[ "${{ github.head_ref }}" == release-please--branches--* ]]; then |
| 128 | + # RC release for release-please PR |
| 129 | + RC_VERSION=$(jq -r '.[]' .release-please-manifest.json | head -1) |
| 130 | + TAG_NAME="v${RC_VERSION}-rc" |
| 131 | + elif [[ "${{ github.ref }}" == refs/heads/beta/* ]]; then |
| 132 | + # Beta release |
| 133 | + BRANCH_NAME="${GITHUB_REF#refs/heads/beta/}" |
| 134 | + SANITIZED=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//') |
| 135 | + TAG_NAME="v${VERSION}-beta-${SANITIZED}" |
| 136 | + fi |
| 137 | +
|
| 138 | + echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT |
| 139 | + echo "is_beta=true" >> $GITHUB_OUTPUT |
| 140 | + echo "Creating beta release: $TAG_NAME" |
| 141 | +
|
| 142 | + create-beta-prerelease: |
| 143 | + needs: [determine-version, build, check-artifacts] |
| 144 | + if: needs.determine-version.outputs.is_beta == 'true' |
| 145 | + runs-on: ubuntu-22.04 |
| 146 | + timeout-minutes: 5 |
| 147 | + permissions: |
| 148 | + contents: write |
| 149 | + steps: |
| 150 | + - name: Enable egress filtering |
| 151 | + uses: bullfrogsec/bullfrog@1831f79cce8ad602eef14d2163873f27081ebfb3 |
| 152 | + with: |
| 153 | + egress-policy: block |
| 154 | + allowed-domains: | |
| 155 | + *.github.qkg1.top |
| 156 | + uploads.github.com |
| 157 | +
|
| 158 | + - name: Checkout |
| 159 | + uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 160 | + with: |
| 161 | + ref: ${{ github.head_ref || github.ref }} |
| 162 | + |
| 163 | + - uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 |
| 164 | + with: |
| 165 | + name: build-artifacts |
| 166 | + |
| 167 | + - name: Create or update beta release |
| 168 | + env: |
| 169 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 170 | + SHA: ${{ github.sha }} |
| 171 | + run: | |
| 172 | + TAG_NAME="${{ needs.determine-version.outputs.version_tag }}" |
| 173 | + IS_BETA="${{ needs.determine-version.outputs.is_beta }}" |
| 174 | +
|
| 175 | + # Delete existing release and tag if they exist |
| 176 | + gh release delete "$TAG_NAME" --yes || true |
| 177 | + git push origin ":refs/tags/$TAG_NAME" || true |
| 178 | +
|
| 179 | + RELEASE_TYPE="--prerelease" |
| 180 | + TITLE="$TAG_NAME" |
| 181 | + NOTES="Automated beta release from branch ${GITHUB_REF#refs/heads/} |
| 182 | +
|
| 183 | + **Testing this beta:** |
| 184 | + \`\`\`yaml |
| 185 | + - uses: bullfrogsec/bullfrog@$SHA |
| 186 | + with: |
| 187 | + _agent-version: '$TAG_NAME' |
| 188 | + egress-policy: block |
| 189 | + allowed-domains: example.com |
| 190 | + \`\`\`" |
| 191 | +
|
| 192 | + # Create release |
| 193 | + tar -czf agent.tar.gz agent/agent |
| 194 | + gh release create "$TAG_NAME" \ |
| 195 | + --title "$TITLE" \ |
| 196 | + --notes "$NOTES" \ |
| 197 | + --target "$SHA" \ |
| 198 | + --prerelease \ |
| 199 | + agent.tar.gz |
| 200 | +
|
| 201 | + test-beta-release: |
| 202 | + needs: [determine-version, create-beta-prerelease] |
| 203 | + if: needs.determine-version.outputs.is_beta == 'true' |
| 204 | + runs-on: ubuntu-22.04 |
| 205 | + timeout-minutes: 5 |
| 206 | + steps: |
| 207 | + - name: Checkout |
| 208 | + uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 209 | + with: |
| 210 | + ref: ${{ github.head_ref || github.ref }} |
| 211 | + |
| 212 | + - name: Test beta release with action |
| 213 | + uses: ./ |
| 214 | + with: |
| 215 | + _agent-version: ${{ needs.determine-version.outputs.version_tag }} |
| 216 | + egress-policy: block |
| 217 | + allowed-domains: www.google.com |
| 218 | + |
| 219 | + - name: Verify blocking works |
| 220 | + run: | |
| 221 | + if curl https://www.google.com --max-time 5 --output /dev/null; then |
| 222 | + echo "Allowed domain works" |
| 223 | + else |
| 224 | + echo "Expected curl to allowed domain to succeed" |
| 225 | + exit 1 |
| 226 | + fi |
| 227 | +
|
| 228 | + if curl https://www.bing.com --max-time 5 --output /dev/null; then |
| 229 | + echo "Block failed - unauthorized domain accessible" |
| 230 | + exit 1 |
| 231 | + fi |
| 232 | +
|
102 | 233 | test-audit: |
103 | 234 | needs: build |
104 | 235 | runs-on: ubuntu-22.04 |
@@ -188,7 +319,7 @@ jobs: |
188 | 319 | egress-policy: block |
189 | 320 |
|
190 | 321 | - name: Make HTTP requests |
191 | | - run: | |
| 322 | + run: | |
192 | 323 | source test/make_http_requests.sh |
193 | 324 | source test/make_docker_pull.sh |
194 | 325 |
|
@@ -315,7 +446,7 @@ jobs: |
315 | 446 | make test.types |
316 | 447 |
|
317 | 448 | pre-release: |
318 | | - if: github.ref == 'refs/heads/main' |
| 449 | + if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
319 | 450 | runs-on: ubuntu-22.04 |
320 | 451 | permissions: |
321 | 452 | contents: write |
|
0 commit comments