Skip to content

Fix the sass_api release #2557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2025
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
29 changes: 29 additions & 0 deletions .github/workflows/release-sass-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This has to be a separate workflow to satisfy pub.dev's somewhat draconian
# requirements for when and how GitHub actions are allowed publish packages.
# Specifically, it requires that each publish action be triggered by a tag that
# contains the version number for that action, so we can't just publish sass_api
# as part of the standard sass release flow because that was triggered by a tag
# with the sass version number.
name: Release sass-api

on:
push:
tags: ['sass-api-[0-9]+.[0-9]+.*']

jobs:
deploy_sass_api:
if: github.event.repository.fork == false
name: Deploy sass_api
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ./.github/util/initialize
with: {github-token: "${{ github.token }}"}

- name: Deploy
run: dart run grinder deploy-sass-api
env:
PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}"
GH_TOKEN: "${{ secrets.GH_TOKEN }}"
GH_USER: sassbot
28 changes: 12 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,29 +95,25 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
# We have to use this rather than the implicit GitHub token so that
# pushing a new tag triggers another action.
token: ${{ secrets.GH_TOKEN }}
- uses: ./.github/util/initialize
with: {github-token: "${{ github.token }}"}

- name: Deploy
run: dart run grinder protobuf pkg-pub-deploy
env: {PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}"}

deploy_sass_api:
name: Deploy sass_api
runs-on: ubuntu-latest
needs: [deploy_pub]

steps:
- uses: actions/checkout@v4
- uses: ./.github/util/initialize
with: {github-token: "${{ github.token }}"}

- name: Deploy
run: dart run grinder deploy-sass-api
env:
PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}"
GH_TOKEN: "${{ secrets.GH_TOKEN }}"
GH_USER: sassbot
- name: Get Sass API version
id: sass-api-version
run: |
echo "version=$(cat pkg/sass_api/pubspec.yaml | sed -nE 's/version: (.*)/\1/p')" | tee --append "$GITHUB_OUTPUT"
# This should be /-separated rather than hyphenated, but pub.dev doesn't
# currently allow that (dart-lang/pub-dev#8690).
- run: git tag sass-api-${{ steps.sass-api-version.outputs.version }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure, but another way this might be broken is that git might complain that "user" is not setup. Maybe we need to add these before creating the tag:

git config user.email 
git config user.name 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe lightweight tags don't include any author information. (Note that the git user isn't set when tagging sass-parser below.)

- run: git push --tag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to push with the implicit ${{ github.token }} that comes from github actions, you need to add permissions to the job definition:

permissions:
  content: write

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, another problem I remember is that pushing with implicit token won't trigger another workflow. So you probably should use ${{ secrets.GH_TOKEN }} in checkout action, that it will trigger the workflow for new tag push.

Copy link
Contributor Author

@nex3 nex3 Apr 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to push with the implicit ${{ github.token }} that comes from github actions, you need to add permissions to the job definition:

permissions:
  content: write

Isn't that inherited from the invocation in ci.yml? deploy_sass_parser is pushing a tag without explicit local permissions below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, another problem I remember is that pushing with implicit token won't trigger another workflow. So you probably should use ${{ secrets.GH_TOKEN }} in checkout action, that it will trigger the workflow for new tag push.

Done.

Copy link
Contributor

@ntkme ntkme Apr 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that inherited

Permission inheritance in reusable workflow is a bit complicated. The permission declared in parent workflow defines the maximum permission child workflows can ask for, but if a child workflow did not explicitly ask for the permission, it won't get inherited from parent automatically.

https://docs.github.com/en/actions/sharing-automations/reusing-workflows#access-and-permissions

Anyways, better to use a PAT so that it guarantee the push event triggers a new workflow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's now using the same setup as deploy_sass_parser including the token it uses for checkout so it should work.


deploy_sass_parser:
name: Deploy sass-parser
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.86.2

* No user-visible changes.

## 1.86.1

* Improve the performance of `file:` URL case canonicalization on Windows and
Expand Down
4 changes: 4 additions & 0 deletions pkg/sass-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.18

* No user-visible changes.

## 0.4.17

* No user-visible changes.
Expand Down
2 changes: 1 addition & 1 deletion pkg/sass-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sass-parser",
"version": "0.4.17",
"version": "0.4.18",
"description": "A PostCSS-compatible wrapper of the official Sass parser",
"repository": "sass/sass",
"author": "Google Inc.",
Expand Down
4 changes: 4 additions & 0 deletions pkg/sass_api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 15.3.2

* No user-visible changes.

## 15.3.1

* No user-visible changes.
Expand Down
4 changes: 2 additions & 2 deletions pkg/sass_api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: sass_api
# Note: Every time we add a new Sass AST node, we need to bump the *major*
# version because it's a breaking change for anyone who's implementing the
# visitor interface(s).
version: 15.3.1
version: 15.3.2
description: Additional APIs for Dart Sass.
homepage: https://github.com/sass/dart-sass

environment:
sdk: ">=3.6.0 <4.0.0"

dependencies:
sass: 1.86.1
sass: 1.86.2

dev_dependencies:
dartdoc: ^8.0.14
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass
version: 1.86.1
version: 1.86.2
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down
2 changes: 2 additions & 0 deletions tool/grind/sass_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ Future<void> deploySassApi() async {
fail("dart pub publish ${pubspec.name} failed");
}

// TODO(nweiz): Remove this when we use this tag to trigger the release
// (blocked by dart-lang/pub-dev#8690).
var response = await client.post(
Uri.parse("https://api.github.com/repos/sass/dart-sass/git/refs"),
headers: {
Expand Down