salsify / action-detect-and-tag-new-version Goto Github PK
View Code? Open in Web Editor NEWA GitHub action to detect and tag new versions of a repo based on changes to its contents
License: MIT License
A GitHub action to detect and tag new versions of a repo based on changes to its contents
License: MIT License
Workflow started to warn:
Release
Theset-output
command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Please, update @actions/core package in source code ๐
The action can't create a tag because of a fatal error of "fatal: unable to access 'repo_url': The requested URL returned error: 403". Probably because it's a private repo?
I have tag-annotation-template: ''
and it is just ignored and the default is used. I know im doing it right because if i have anything in the string it works.
let annotationTemplate = getInput('tag-annotation-template') || 'Released version {VERSION}';
this line is whats causing the problem when getInput('tag-annotation-template')
is blank its considered false and just defaults to
Released version {VERSION}
so there's no way to not have an annotation
my current workaround is to just use v1.0.3 which doesn't have annotations at all
uses: salsify/[email protected]
personally i think you should just change it to
let annotationTemplate = getInput('tag-annotation-template') || '';
and let the default operation have no annotation and let users add an annotation if they want by specifying tag-annotation-template
We frequently use this repo and then pair it with a not-tiny follow up bash script to do the following logic:
prod_build
to true
.-dev.$CURRENT_COMMIT
to the end of it.I wanted to see if there was interest in this repo supporting some or all of this logic as I've used it across dozens of projects and it's so templated at this point as to seem worth adding into the project itself if others find it useful.
- name: Version pre-release
id: gen_version
run: |
set -ex
previous_version="${{steps.detect_version.outputs.previous-version}}"
current_version="${{steps.detect_version.outputs.current-version}}"
current_version_existing_tag="$(git ls-remote --tags origin | cut -d$'\t' -f2 | grep "^refs/tags/${current_version}$" || true)"
# If the version hasn't changed or if the version has already been released then it's a dev build
if [ "$previous_version" = "$current_version" ] || [ "refs/tags/$current_version" = "$current_version_existing_tag" ]; then
echo "Version has NOT changed. This is a dev build."
export CURRENT_COMMIT="$(git rev-parse --short HEAD)"
export NEW_PACKAGE_VERSION="$(npx semver --increment minor "$current_version")-dev.$CURRENT_COMMIT"
echo "::set-output name=new_version::$NEW_PACKAGE_VERSION"
echo "::set-output name=prod_build::false"
echo "::set-output name=npm_tag::dev"
else
echo "Version has changed. This is a prod build!"
echo "::set-output name=new_version::$current_version"
echo "::set-output name=prod_build::true"
echo "::set-output name=npm_tag::latest"
fi
Here is my .github/workflows/ci.yml
:
name: CI
on:
pull_request:
branches: [ "main" ]
jobs:
linux-ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2 # https://github.com/marketplace/actions/detect-and-tag-new-version#usage
- uses: salsify/action-detect-and-tag-new-version@v2 # https://github.com/marketplace/actions/detect-and-tag-new-version#usage
with:
version-command: |
yq '.version' pubspec.yaml
When I run it in github I got error Error: Command failed with exit code 1: git checkout refs/pull/3/merge
What am I missing here ?
In pubspec.yaml
I got:
# ...
version: 0.0.1+3
# ...
Getting this warning on my GitHub actions:
Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: salsify/action-detect-and-tag-new-version.
Thanks for the great work here!
I'm suggesting a default value for version-command
, in case a pubspec.yaml
file (Flutter) is found:
grep "version\: " ./pubspec.yaml | sed 's/version\: //g'
I've just checked that this works on my flutter repository.
I don't guarantee it's 100% fault proof, pretty sure it's better than nothing.
Hi, we've came across this action recently and it does exactly what we need. Thank you for sharing.
That being said there is one scenario in which the action wouldn't work. Here's how you could reproduce it. Please disregard version-command that doesn't make sense, it's just for testing purposes.
.github/workflows/tag.yml
name: tag-argocd
on:
pull_request:
branches:
- argocd
jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: salsify/[email protected]
with:
create-tag: false
version-command: |
echo "123"
This workflow always result in failure.
Run salsify/[email protected]
with:
create-tag: false
version-command: echo "123"
tag-template: v{VERSION}
tag-annotation-template: Released version {VERSION}
Previous version: 123
Error: Command failed with exit code 1: git checkout refs/pull/18/merge
error: pathspec 'refs/pull/18/merge' did not match any file(s) known to git
Would you have any advice how to fix that?
I am using the action in conjunction with poetry like so:
- name: Detect and tag new version
id: check-version
if: steps.check-parent-commit.outputs.sha
uses: salsify/action-detect-and-tag-new-version@624bb847c54529c8c4175cb36b534b101daae484
with:
version-command: |
bash -o pipefail -c "poetry version | awk '{ print \$2 }'"
I doubt that it has to do with the version-command as the error message is:
File not found: '/home/runner/work/_actions/salsify/action-detect-and-tag-new-version/624bb847c54529c8c4175cb36b534b101daae484/dist/index.js'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.