Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.100
- name: Run docker-compose
run: docker-compose up -d
# `docker-compose` (Compose v1) is no longer installed on GitHub-hosted
# runners; v2 is a docker subcommand. --wait blocks until the localstack
# healthcheck passes, instead of racing it from the test step.
- name: Run docker compose
run: docker compose up -d --wait
- name: Run Integration Tests
run: dotnet test ./test/SqsPoller.Extensions.Publisher.Tests.Integration/SqsPoller.Extensions.Publisher.Tests.Integration.csproj
100 changes: 100 additions & 0 deletions .github/workflows/publish-codeartifact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Publish NuGet package to CodeArtifact

# Publishes on an annotated version tag, not on every push to master. The package
# version comes from the csproj, so a push-triggered publish would fail on any
# commit that does not bump it. Tagging is already how this repository is versioned.
on:
push:
tags:
- 'v*'
workflow_dispatch:

permissions:
id-token: write
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
publish:
# GitHub-hosted: the self-hosted `gha-runner-scale-set` label is not available
# to this repository, so jobs targeting it stay queued forever. OIDC works the
# same on hosted runners.
runs-on: ubuntu-latest
env:
CODEARTIFACT_DOMAIN: "idt"
CODEARTIFACT_DOMAIN_OWNER: "416223954868"
CODEARTIFACT_REPO: "team_caf-nuget"
CODEARTIFACT_TOOL: "dotnet"

steps:
- uses: actions/checkout@v4

- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::101838717447:role/github-actions-role
aws-region: ${{ secrets.AWS_REGION || 'us-east-1' }}

- name: Log in to CodeArtifact
run: |
aws codeartifact login --tool ${{ env.CODEARTIFACT_TOOL }} \
--domain ${{ env.CODEARTIFACT_DOMAIN }} \
--domain-owner ${{ env.CODEARTIFACT_DOMAIN_OWNER }} \
--repository ${{ env.CODEARTIFACT_REPO }}

# The tag is the source of truth for the released version: `-p:Version` overrides
# the csproj, so v2.1.0 always produces 2.1.0. Without this the csproj decides,
# and tagging without bumping it republishes the old version, which
# --skip-duplicate then turns into a silently green no-op.
#
# workflow_dispatch runs from a branch, where GITHUB_REF_NAME is not a version;
# there the csproj value is used unchanged.
#
# -p:GeneratePackageOnBuild=false: both csproj set GeneratePackageOnBuild=true,
# which wires packing into build. On SDK 10 `dotnet pack` then does not rebuild
# and fails with NU5026 (dll not found on disk); SDK 8 tolerated it.
#
# The two library projects are packed explicitly. `dotnet pack` on the solution
# also packs sample/SqsPoller.Sample.Publisher and sample/SqsPoller.Sample.Subscriber,
# which are not products and would be pushed to the feed as 1.0.0.
- name: Pack
run: |
VERSION_ARG=""
if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then
VERSION="${GITHUB_REF_NAME#v}"
if ! printf '%s' "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then
echo "::error::Tag '$GITHUB_REF_NAME' does not yield a valid version ('$VERSION'). Expected vMAJOR.MINOR.PATCH[-suffix]."
exit 1
fi
VERSION_ARG="-p:Version=$VERSION"
echo "Releasing version $VERSION from tag $GITHUB_REF_NAME"
else
echo "Not a tag ref; using the version declared in the csproj."
fi

dotnet pack src/SqsPoller/SqsPoller.csproj \
-c Release -o ./artifacts -p:GeneratePackageOnBuild=false $VERSION_ARG
dotnet pack src/SqsPoller.Extensions.Publisher/SqsPoller.Extensions.Publisher.csproj \
-c Release -o ./artifacts -p:GeneratePackageOnBuild=false $VERSION_ARG

# --skip-duplicate makes a re-run of the same tag a no-op instead of a
# failure. CodeArtifact rejects overwriting an existing version.
- name: Push to CodeArtifact
run: |
dotnet nuget push "./artifacts/*.nupkg" \
--source ${{ env.CODEARTIFACT_DOMAIN }}/${{ env.CODEARTIFACT_REPO }} \
--api-key unused \
--skip-duplicate

- name: Summary
run: |
echo "Pushed to ${CODEARTIFACT_DOMAIN}/${CODEARTIFACT_REPO}:" >> "$GITHUB_STEP_SUMMARY"
ls -1 ./artifacts/*.nupkg | sed 's#.*/# - #' >> "$GITHUB_STEP_SUMMARY"
35 changes: 0 additions & 35 deletions .github/workflows/publish-nuget.yml

This file was deleted.

83 changes: 83 additions & 0 deletions .github/workflows/publish-prerelease-codeartifact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Publish NuGet prerelease to CodeArtifact

# Publishes a prerelease build of each pull request so consumers can test a change
# before it is tagged. Replaces the previous workflow that pushed prereleases to
# public nuget.org.
#
# Pull requests opened from a fork do not receive `id-token: write`, so the OIDC
# step cannot assume the AWS role there and this workflow will fail for them.
# Branches in this repository are unaffected.
on:
pull_request:
branches:
- master

permissions:
id-token: write
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
publish-prerelease:
# GitHub-hosted: the self-hosted `gha-runner-scale-set` label is not available
# to this repository, so jobs targeting it stay queued forever. OIDC works the
# same on hosted runners.
runs-on: ubuntu-latest
env:
CODEARTIFACT_DOMAIN: "idt"
CODEARTIFACT_DOMAIN_OWNER: "416223954868"
CODEARTIFACT_REPO: "team_caf-nuget"
CODEARTIFACT_TOOL: "dotnet"

steps:
- uses: actions/checkout@v4

- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::101838717447:role/github-actions-role
aws-region: ${{ secrets.AWS_REGION || 'us-east-1' }}

- name: Log in to CodeArtifact
run: |
aws codeartifact login --tool ${{ env.CODEARTIFACT_TOOL }} \
--domain ${{ env.CODEARTIFACT_DOMAIN }} \
--domain-owner ${{ env.CODEARTIFACT_DOMAIN_OWNER }} \
--repository ${{ env.CODEARTIFACT_REPO }}

# -p:GeneratePackageOnBuild=false: see the release workflow; without it SDK 10
# fails with NU5026.
# The csproj declares <Version>X.Y.Z$(VersionSuffix)</Version>, so the suffix
# is concatenated directly and must carry its own leading dash.
- name: Pack prerelease
run: |
SUFFIX="-prerelease-$(date +%Y%m%d%H%M%S)"
dotnet pack src/SqsPoller/SqsPoller.csproj \
-c Release -o ./artifacts -p:GeneratePackageOnBuild=false --version-suffix "$SUFFIX"
dotnet pack src/SqsPoller.Extensions.Publisher/SqsPoller.Extensions.Publisher.csproj \
-c Release -o ./artifacts -p:GeneratePackageOnBuild=false --version-suffix "$SUFFIX"

# Both package names are also reachable through the feed's public nuget.org
# external connection, so CodeArtifact defaults them to publish=BLOCK. Each
# needs publish=ALLOW,upstream=BLOCK set once via
# `aws codeartifact put-package-origin-configuration`; otherwise the push
# below returns a bare 400.
- name: Push to CodeArtifact
run: |
dotnet nuget push "./artifacts/*.nupkg" \
--source ${{ env.CODEARTIFACT_DOMAIN }}/${{ env.CODEARTIFACT_REPO }} \
--api-key unused \
--skip-duplicate

- name: Summary
run: |
echo "Prerelease pushed to ${CODEARTIFACT_DOMAIN}/${CODEARTIFACT_REPO}:" >> "$GITHUB_STEP_SUMMARY"
ls -1 ./artifacts/*.nupkg | sed 's#.*/# - #' >> "$GITHUB_STEP_SUMMARY"
35 changes: 0 additions & 35 deletions .github/workflows/publish-prerelease-nuget.yml

This file was deleted.

Binary file removed nuget-apikey
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<Authors>Alexey Bogdan</Authors>
<Company>Alexey Bogdan</Company>
<Description>A small library that helps ASP.NET Core applications easily consume messages from a SQS queue</Description>
<RepositoryUrl>https://github.com/AlexeyBogdan95/SqsPoller</RepositoryUrl>
<PackageProjectUrl>https://www.nuget.org/packages/SqsPoller/</PackageProjectUrl>
<RepositoryUrl>https://github.com/coretech/SqsPoller</RepositoryUrl>
<PackageProjectUrl>https://github.com/coretech/SqsPoller</PackageProjectUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
Expand Down
4 changes: 2 additions & 2 deletions src/SqsPoller/SqsPoller.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<Authors>Alexey Bogdan</Authors>
<Company>Alexey Bogdan</Company>
<Description>A small library that helps ASP.NET Core applications easily consume messages from a SQS queue</Description>
<RepositoryUrl>https://github.com/AlexeyBogdan95/SqsPoller</RepositoryUrl>
<PackageProjectUrl>https://www.nuget.org/packages/SqsPoller/</PackageProjectUrl>
<RepositoryUrl>https://github.com/coretech/SqsPoller</RepositoryUrl>
<PackageProjectUrl>https://github.com/coretech/SqsPoller</PackageProjectUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
Expand Down
Loading